This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC CPP not expanding macro correctly?


AWLaFramboise at aol dot com wrote:-

> Hi,
> 
> I have found what appears to be very odd behavior, possibly a bug, according to my reading of the C standard.  Test case:
> -----
> #define FIRST() FUNC
> #define SECOND() ()
> #define FUNC() 0
> int main() {
>   return FIRST()SECOND();
> }
> -----
> After preprocessing (translation stage 4), this code looks like (according to gcc 3.2.2 with gcc -E):
> int main() {
>   return FUNC();
> }
> 
> Question is: Why does this code not expand to this?
> int main() {
>   return 0;
> }

Because the preprocessor only checks for '(' once, and it doesn't see
'(' it sees SECOND.

Neil.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]