FYI, recent gcc vs. glibc's `#define printf(...' vs texinfo-4.0b

Nathan Sidwell nathan@codesourcery.com
Thu May 3 01:02:00 GMT 2001


Alexandre Oliva wrote:

> The problem is in the program that assumes any C standard function is
> not implemented as a macro.  The C Standard explicitly allows a number
> of functions to be implemented as preprocessor macros, and it doesn't
> allow preprocessor directives within macro expansions.
We have a problem here.
printf is a varadic function
in C89 there are no varadic macros
ergo, a programmer might reasonably deduce printf cannot be a macro

can the glibc behaviour be gated on STDC_VERSION?
#if !__STDC__ || __STDC_VERSION__ >= 199909 /* or whatever the right number is */
#define printf(format, ...) (fprintf (stdout, format, __VA_ARGS__))
#endif

in C99 the case is different of course.

nathan

-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org



More information about the Gcc-bugs mailing list