This is the mail archive of the gcc@gcc.gnu.org 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


At 14:52 01.08.2001, Andreas Jaeger wrote:
>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,

BTW, why do we need this at all in the glibc sources? gcc-3.0 can optimize 
printf the same way as fprintf, I don't see any advantages of this #define...

Franz.


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