On Tue, 2 Jan 2001, David Elliott wrote:
> Attached is a simple .c file (not even a program, intended for input for the
> preprocessor) and the output when run with the processors from the latest
> RH7 errata GCC 2.96 and the RH7 KGCC 2.91.66 (egcs 1.1.2). I included the
> output from stderr of the newer preprocessor as well.
>
> This should be a suitable simple testcase for a preprocessor.
No it's not a good testcase. The reason is:
#define A1(a) (A2(##a))
#define B1(a) (B2(##a))
Both A1 and B1 use the construct that causes problems.
Here's the testcase I wrote:
#define GetObject You cannot use GetObject in this context
#define ICOM_FN(xfn) fn ## xfn
#define DECLARE1(xfn) void ICOM_FN(xfn) (void);
#define DECLARE2(xfn) void ICOM_FN(##xfn) (void);
ICOM_FN(GetObject)
DECLARE1(GetObject)
DECLARE2(GetObject)
Here's what I get with various compilers:
* gcc 2.95
GNU CPP version 2.95.2 20000220 (Debian GNU/Linux) (i386 Linux/ELF)
fnGetObject
void fnYou_cannot_use_GetObject_in_this_context (void);
void fnGetObject (void);
The above is what I expect.
* 'gcc 2.97' 20001002
GNU CPP version 2.97 20001002 (experimental) (cpplib) (i386 Linux/ELF)
test.c:6:38: warning: nothing can be pasted after this token
fnGetObject
void fnYou_cannot_use_GetObject_in_this_context (void);
void fnYou_cannot_use_GetObject_in_this_context (void);
That's bad. It means that with such a compiler we have to duplicate
all the ICOM_METHOD and ICOM_CALL macros.
* 'gcc 2.97' 20001228
GNU CPP version 2.97 20001228 (experimental) (cpplib) (i386 Linux/ELF)
fnGetObject
void fnYou_cannot_use_GetObject_in_this_context (void);
test.c:11:1: warning: pasting "(" and "GetObject" does not give a valid
preprocessing token
void fnGetObject (void);
So it seems the problem has been fixed in the latest revisions of
gcc. But we still get the warning.
* SunPro 4.0
#ident "acomp: SC4.0 18 Oct 1995 C 4.0"
fnGetObject
void fnYou_cannot_use_GetObject_in_this_context ( void ) ;
void fnGetObject ( void ) ;
The above shows that it also works with Sun's C compiler (on a Sun
Sparc). Patrick's tests seems to confirm that although it seems his
(newer) compiler generates a warning.
--
Francois Gouget [EMAIL PROTECTED] http://fgouget.free.fr/
RFC 2549: ftp://ftp.isi.edu/in-notes/rfc2549.txt
IP over Avian Carriers with Quality of Service