This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC CPP not expanding macro correctly?
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: AWLaFramboise at aol dot com
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 23 Apr 2003 06:59:22 +0100
- Subject: Re: GCC CPP not expanding macro correctly?
- References: <2B34188D.09008BF3.E8E247C1@aol.com>
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.