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]

GCC CPP not expanding macro correctly?


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


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