This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

preprocessor/2790: Preprocessor has problems using ## to construct valid C code.



>Number:         2790
>Category:       preprocessor
>Synopsis:       Preprocessor has problems using ## to construct valid C code.
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed May 09 05:36:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Tim Van Holder
>Release:        3.0 20010430 (prerelease)
>Organization:
Falcon Software N.V.
>Environment:
System: Linux bender.falconsoft.be 2.2.16-3 #19 Thu Nov 30 11:39:13 CET 2000 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --with-gcc-version-trigger=/home/tim/gnu/gcc/gcc/version.c --host=i686-pc-linux-gnu --with-version-specific-runtime-libs --prefix=/opt/gcc3
>Description:

gcc's preprocessor gives warnings for what I believe to be valid code.

>How-To-Repeat:

Try to compile the code below.

struct bar {
  int a;
  int b;
};

/* This simplifies the basic 'property get'-type functions */
#define TAKE_FUNCTION(foo)	\
int take_##foo(struct bar* me)	\
{				\
  if (me == 0)			\
    return 0;			\
  return me->##foo;		\
}

TAKE_FUNCTION(a)
TAKE_FUNCTION(b)

#undef TAKE_FUNCTION

You will get
 warning: pasting "->" and "a" does not give a valid preprocessing token
 warning: pasting "->" and "b" does not give a valid preprocessing token

The same happens if (*me).##foo is used.

>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]