GCC CPP not expanding macro correctly?

AWLaFramboise@aol.com AWLaFramboise@aol.com
Wed Apr 23 04:37:00 GMT 2003


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;
}

Adding another layer of indirection or re-arranging #define's do not seem to help.

I have been scouring the standard and the web, and I have been unable to find a reason for this.  The only other compilers I have access to are known to have CPP bugs (msvc, edg, borland), so I do not have a standard for comparison.

Is this a bug?


Aaron



More information about the Gcc mailing list