This is the mail archive of the gcc@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]
Other format: [Raw text]

RE: Gcc3.4.2 C preprocessor problem


> -----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....


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