This is the mail archive of the gcc-bugs@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> 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>

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