[cfe-dev] #define behavior
hartmut.kaiser at gmail.com
Thu Dec 6 07:36:34 PST 2007
> > > Standard C works on tokens, not text, so the code is invalid as
> > > * and = are two separate tokens.
> > The preprocessor works on preprocessor tokens (translation
> phase 4),
> > which are different from the tokens the compiler is working on. The
> > preprocessor tokens are converted into tokens at
> translation phase 7
> > only. Any preprocessor token not matching the syntax of a
> token is an
> > error at this point.
> Well, is undefined behaviour. The standard has no concept of
> error per se, only "must be diagnosed" and "failure to
> successfully translate", the latter applying to #error exclusively.
Thanks for clarifying this.
> > Further, IIUC concatenating two tokens (using ##) forming another
> > (invalid) pp token results in undefined behaviour in C90/C++ but is
> > allowed in C99/C++09. Gcc issues a warning here (I'm not
> sure about clang) for C90/C++.
> There is no difference between C90 and C99 here. I'm the
> person that made it a hard error in GCC; it is not a warning.
> That is and was my preference. :)
Ok, but it is allowed in C99, and undefined behaviour in C++98. Admittedly,
I was not sure about C90.
More information about the cfe-dev