Re: problem with pasting two tokens together in gcc 3.4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 18 May 2005, Deepak Soi moaned:
> Hi, Yes, you are right problem we are facing is with pasting two
> tokens together,

You shouldn't use ## to paste two tokens together if there result would
be parsed as two tokens (as is the case below). Its purpose is to paste
two tokens together to yield *one* token. That is,

#define IdentifierComposition (x, y) x##y
IdentifierComposition(Some,Function)

would yield the *single token* `SomeFunction'.

>                  but what I am unable to understand is why its
> compiling properly with older gcc versions. Is there any change in
> gcc3.4 handling of macros.

The preprocessor was rewritten completely before GCC 3.0, and has got
progressively stricter (i.e. more standards-compliant) since then.
I believe even GCC-3.0 complained about this (erroneous) construct,
but I'm not certain.

>  find.cxx:723:1: pasting "DbNet" and "*" does not give a valid preprocessing token.
>   find.cxx:723:1: pasting "Net" and "*" does not give a valid
> preprocessing token.
>   find.cxx:723:1: pasting "FindFromDbNet" and "(" does not give a
> valid preprocessing token.

You shouldn't be using ## in any of those cases. Exactly how your macros
should be restructured depends on what the macros are doing, but probably
you can replace a##b with a simple `a b'.

-- 
`End users are just test loads for verifying that the system works, kind of
 like resistors in an electrical circuit.' - Kaz Kylheku in c.o.l.d.s

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux