preprocessor weirdness

Geoff Keating geoffk@cygnus.com
Sun Jul 9 21:20:00 GMT 2000


<lindholm@possessive.stanford.edu> writes:

> #define _VARIANT_BOOL    /##/

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

Yes, it's not ISO-compliant.  I think it's most likely a typo for /**/.

I believe that this results in undefined behaviour if the macro is
ever used, because '//' is not a preprocessing token.  If I'm wrong,
then what you end up with is a '//' in the token stream, which would
be a syntax error.  It doesn't comment out the rest of the line
because comments are removed before macro replacement is done.

-- 
- Geoffrey Keating <geoffk@cygnus.com>


More information about the Gcc-bugs mailing list