[cfe-dev] #define behavior

'Neil Booth' neil at daikokuya.co.uk
Thu Dec 6 14:32:00 PST 2007


Hartmut Kaiser wrote:-

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

I don't understand what you mean "is allowed".  An implementation
can choose to make undefined behaviour allowed in any particular
case, but invalid pasting is not required to be accepted by any of
the standards; it is undefined in all (or can you quote
something to the contrary?)

C++'s preprocessor is essentially C90's with a couple of tweaks
for booleans and UCNs; nothing else changes.

Neil.



More information about the cfe-dev mailing list