This is the mail archive of the 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]

Re: Strange behaviour gcc 3.0

Igmar Palsenberg <> writes:

> On 1 Aug 2001, Alexandre Oliva wrote:
>> On Aug  1, 2001, Igmar Palsenberg <> 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

But note that ISO C allows every function to be a macro,

 Andreas Jaeger
  SuSE Labs

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