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]

Re: preprocessor weirdness


lindholm@possessive.stanford.edu wrote:-

> /* ANSI C/C++ reserve bool as keyword */
> #define _VARIANT_BOOL    /##/
> #endif
> 
> I take it that, under VC++, _VARIANT_BOOL is now equal to "//" and where
> it appears later in code, it comments out the rest of the line. That
> doesn't happen in g++, it gives me an error:

Yuk.  Experimenting I've discovered that Borland and MS use a
single-pass text-based preprocessor (MS are clever in that they get
trigraphs almost right in the single pass, Borland don't bother with
trigraphs and just provide a filter).

MS chose to do it so that the above thing is rescanned by the same
code that recognises comments, turning the line into a comment.  As
Geoff said, this is definitely wrong.  Indeed, it's even given as an
example of wrongness in the standard (6.4.9 para 3):-

#define glue(x, y) x##y
glue(/, /)k();   // syntax error, not a comment.

They get a whole load of other things wrong in the preprocessor, too.
Unfortunately for Borland they have to compile MS headers and code, so
they have no choice but to copy most of MS breakage.

I think the chances of GCC ever accepting this are close to zero.

Neil.

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