Gcc3.4.2 C preprocessor problem
Dave Korn
dk@artimi.com
Fri Nov 19 17:12:00 GMT 2004
> -----Original Message-----
> From: gcc-owner On Behalf Of Dave Korn
> Sent: 19 November 2004 16:19
> > -----Original Message-----
> > From: gcc-owner On Behalf Of Andrew Walrond
> > Sent: 19 November 2004 16:15
>
> > Given this macro:
> >
> > #define PRESENT_OR_SET_GENERIC(xxx) \
> > if (!drawops. ## xxx) \
> > drawops. ## xxx = generic_ ## xxx;
> >
> > this line:
> >
> > PRESENT_OR_SET_GENERIC(draw_hline);
> >
> > gives this error when compiled
> >
> > gcc -c -o init.o init.c
> > init.c:59:1: pasting "." and "draw_hline" does not give a
> > valid preprocessing
> > token
> >
> > Is this a bug, or some change of behaviour I am unaware of?
>
> Your code is buggy. Preprocessor pasting concatenates two
> tokens into one
> single one. But you want the . operator to be a separate
> token from the
> struct member. Just omit the pasting and you'll be fine.
Just to clarify: you still want to paste the "generic_" prefix. But you
don't paste the dot operator. This one should work:
#define PRESENT_OR_SET_GENERIC(xxx) \
if (!drawops. xxx) \
drawops. xxx = generic_ ## xxx;
cheers,
DaveK
--
Can't think of a witty .sigline today....
More information about the Gcc
mailing list