This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Gcc 3.0, printf() and exim-3.30
- To: Nix <nix at esperi dot demon dot co dot uk>
- Subject: Re: Gcc 3.0, printf() and exim-3.30
- From: Russ Allbery <rra at stanford dot edu>
- Date: 21 Jun 2001 01:41:31 -0700
- Cc: Vadim Vygonets <vadik at vygo dot net>, gcc at gcc dot gnu dot org
- Organization: The Eyrie
- References: <20010619161158.F9339@vygo.net> <87bsnihitd.fsf@loki.wkstn.nix>
Nix <nix@esperi.demon.co.uk> writes:
> Nope; printf is not a macro, and GCC does not define printf :)
You're correct that GCC does not define printf, of course, but in recent
versions of glibc, printf is indeed a macro.
/usr/include/stdio.h:
/* If we are compiling with optimizing read this file. It contains
several optimizing inline functions and macros. */
#ifdef __USE_EXTERN_INLINES
# include <bits/stdio.h>
#endif
/usr/include/bits/stdio.h:
#ifdef __USE_EXTERN_INLINES
/* Since version 2.97 GCC knows about `fprintf' and can optimize certain
cases. Help gcc to optimize more code by mapping `printf' to the known
`fprintf' function. Unfortunately we have to use a macro. */
# if __GNUC_PREREQ (2,97)
# define printf(fmt, args...) fprintf (stdout, fmt, ##args)
# endif
You didn't see this before because glibc doesn't enable this optimization
unless the version of gcc is greater than 2.96.
firebird1:/root# rpm -q glibc
glibc-2.2-12
(Out of curiosity, is that little aid to GCC as braindead as it looks?
I'd think that if GCC optimized fprintf, it would pick up printf too....)
--
Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>