Strange behaviour gcc 3.0
Igmar Palsenberg
i.palsenberg@jdimedia.nl
Wed Aug 1 05:48:00 GMT 2001
On 1 Aug 2001, Alexandre Oliva wrote:
> On Aug 1, 2001, Igmar Palsenberg <i.palsenberg@jdimedia.nl> wrote:
>
> > printf("bogus"
> > #ifdef TEST
> > "testing"
> > #endif
> > );
>
> > [root@wrkst SPECS]# gcc -O2 -o x x.c
> > x.c:7:1: directives may not be used inside a macro argument
> > x.c:7:1: unterminated argument list invoking macro "printf"
> > x.c: In function `main':
> > x.c:10: parse error before ')' token
>
> > Code didn't change. This really strikes me.. Anyone can comment on this ??
>
> printf is a macro (don't ask me why; it's a glibc implementation
> detail that is authorized by the C Standard), and there can't be
> preprocessor directives inside a macro argument list.
It's indeed in bits/stdio.h.
Is there a define available to see if I'm using gcc 3.0 ?? Older versions
have no problem with above code, and the #ifdef in printf() is massively
used in the programs I'm recompiling.
I can override the optimize to use -O0, but that might give other
problems..
For now, I'll hack glibc.
Regards,
Igmar
--
Igmar Palsenberg
JDI Media Solutions
Boulevard Heuvelink 102
6828 KT Arnhem
The Netherlands
mailto: i.palsenberg@jdimedia.nl
PGP/GPG key : http://www.jdimedia.nl/formulier/pgp/igmar
More information about the Gcc
mailing list