This is the mail archive of the gcc-bugs@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: FYI, recent gcc vs. glibc's `#define printf(...' vs texinfo-4.0b


Jim Meyering wrote:-

> Here's the pared-down info.c:
> 
> ---------------------------------
>   #define printf(fmt, args...) fprintf (stdout, fmt, ## args)
> 
>   static void
>   info_short_help ()
>   {
>     printf ("%s",
>   #ifdef __MSDOS__
>   "a"
>   #else
>   "b"
>   #endif
>             );
>   }
> ---------------------------------
> 
> Compiling the above with /usr/bin/gcc succeeded.
> 
> If the definition of printf above (extracted from glibc's stdio.h)
> is valid, then I suppose this is a problem with gcc.

No, it is caused by a (silly) glibc macro.  Basically, glibc defines
printf as a macro, which it is theoretically entitled to do, and that
causes your code to barf since you have conditionals within the macro.
You need to put the printfs inside the conditionals.

Neil.


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