On 2007-08-19 at 03:17:59 [+0200], Ryan Leavengood <leavengood@xxxxxxxxx> wrote: > On 8/18/07, François Revol <revol@xxxxxxx> wrote: > > > > The ## is supposed to be able to concat 2 strings to form an > > identifier. > > Indeed. > > > It should work in 2.95 as well. > > But this construct looks like it tries to create preprocessor stuff > > from a define, while the preprocessor only has a single pass, I wonder > > how it can even work with gcc4. > > I'm not exactly sure, but it does indeed work with GCC 4, and also > with whatever compilers are used on Mac OS X and Windows. So I don't > think it is an invalid construct. My understanding was that the > preprocessor will continue to process the input until all macros have > been expanded. So the single pass thing isn't quite true. > > > Of course it preprocesses this into > > (defined( WFT_... > > > > and passes this to the compiler which doesn't know what defined is > > about. > > The errors are all in the preprocessor, it never passes it off to the > compiler. According to the ISO C++ standard (my copy is: ISO/IEC 14882, Second edition, 2003-10-15) about conditional inclusion (i.e. #if directives): "Prior to evaluation, macro invocations in the list of preprocessing tokens that will become the controlling constant expression are replaced (except for those macro names modified by the *defined* unary operator), just as in normal text. If the token *defined* is generated as a result of this replacement process ... the behavior is undefined." So, unless the standard changed in that respect since October 2003, the code you stumbled upon uses preprocessor behavior undefined by the standard and implemented differently by gcc 4 and 2.95.3. CU, Ingo