Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!apple!amdahl!tej From: tej@uts.amdahl.com (Tejkumar Arora) Newsgroups: comp.lang.c Subject: Macro expansions by 2 different C preprocessors Message-ID: Date: 9 Apr 91 18:39:57 GMT Reply-To: tej@amdahl.uts.amdahl.com (Tejkumar Arora) Distribution: usa Organization: Amdahl Corporation, Sunnyvale CA Lines: 40 I will use an example to illustrate the problem. Consider a file x.h some of whose contents are as follows: ------------------------------------- ..... int major(); .... #define major(x) _major(SOMECONST, x) /* _major() returns a value of type int */ ------------------------------------- Now Consider this little program: ------------------------------------- #include "x.h" struct foo { ..... sometype major; .... }; main(){ .... ... major(mumble) } ------------------------------------- I have compiled this program using two different compilers. compiler A: fails to compile. gets stuck at the field major in struct foo. thinks it is a macro and complains of missing argument. compiler B: compiles successfully. determines from context & usage that the field major is not a macro.... Does someone know what the ANSI standards say about macro expansion?. I tend to think that B is the way to go since it preprocesses intelligently, and as far as I can see, B does not have to compromise any other functionality to be able to do this. Some are of the opinion that this is just special casing and is not a good feature. what do you think? Thanks for your time, -Tej (tej@amdahl.com)