GCC CPP not expanding macro correctly?
Segher Boessenkool
segher@koffie.nl
Fri Apr 25 07:16:00 GMT 2003
Neil Booth wrote:
> Segher Boessenkool wrote:-
>
>>Try this:
>>
>>-- 8< --
>>#define FIRST() FUNC
>>#define SECOND() ()
>>#define FUNC() 0
>>#define CLUNK(x, y) x y
>>int main() {
>> return CLUNK(FIRST(), SECOND());
>>}
>>-- 8< --
>>
>>Yes it's ugly, and it fails on some compilers. Not on GCC, though ;)
>
> What does it fail on?
(Older) CodeWarrior, at least -- it will work with
-- 8< --
#define FIRST() FUNC
#define SECOND() ()
#define FUNC() 0
#define TIE(x, y) x ## y
#define CLUNK(x, y) TIE(x, y)
int main() {
return CLUNK(FIRST(), SECOND());
}
-- 8< --
but that's not really valid C (the result of the ## isn't a valid
preprocessing token).
Some MSVC version have a problem with the original, too, IIRC.
Segher
More information about the Gcc
mailing list