This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Strange behaviour gcc 3.0
- To: Igmar Palsenberg <i dot palsenberg at jdimedia dot nl>
- Subject: Re: Strange behaviour gcc 3.0
- From: Andreas Jaeger <aj at suse dot de>
- Date: Wed, 01 Aug 2001 14:52:55 +0200
- Cc: Alexandre Oliva <aoliva at redhat dot com>, <gcc-bugs at gcc dot gnu dot org>,<gcc at gcc dot gnu dot org>
- References: <Pine.LNX.4.33.0108011440220.28577-100000@jdi.jdimedia.nl>
Igmar Palsenberg <i.palsenberg@jdimedia.nl> writes:
> 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.
ISO C99 allows you to #undef printf, just do after inclusion of
stdio.h
But note that ISO C allows every function to be a macro,
Andreas
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj