preprocessor weirdness

lindholm@possessive.stanford.edu lindholm@possessive.stanford.edu
Sun Jul 9 20:23:00 GMT 2000


I'm trying to get g++ to parse the Win2k DDK header files (not to produce
code, it's for a semantic-checking project). I came across an error on
this rather unusual code (in wtypes.h of the DDK):

#if !__STDC__ && (_MSC_VER <= 1000)
/* For backward compatibility */
typedef VARIANT_BOOL _VARIANT_BOOL;

#else
/* 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:

/home/lindholm/WINDDK/2195/inc/oaidl.h:439: parse error before `/'
/home/lindholm/WINDDK/2195/inc/oaidl.h:454: parse error before `/'

I've never seen anything like this before, so I'm guessing that the author
was just taking advantage of a quirk in the VC++ parser. Is this right?
This isn't ANSI-compliant code, is it?





More information about the Gcc mailing list