This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: printf optimiziation in gcc-3.2.x
- From: Andreas Jaeger <aj at suse dot de>
- To: Petko Manolov <petkan at users dot sourceforge dot net>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 10 Mar 2003 12:49:45 +0100
- Subject: Re: printf optimiziation in gcc-3.2.x
- References: <Pine.LNX.4.50.0303101311280.389-100000@tequila.rakia.org>
Petko Manolov <petkan at users dot sourceforge dot net> writes:
> Hi there,
>
> I wrote my own 'printf()' for an embedded application and after compiling
> it with gcc-3.2.2 i got this when i tried to link the objs:
>
> tmp.o(.text+0x9): In function `test':
> : undefined reference to `puts'
> tmp.o(.text+0x18): In function `test':
> : undefined reference to `putchar'
>
> It turned out that gcc is converting 'printf' to 'puts' and 'putchar' and
> later the linker can not (of course) find those symbols. I was using a
> command line like:
>
> gcc -Wall -O2 -fomit-frame-pointer -nostdinc -c tmp.c
>
> Tried the same with gcc-2.95 and everything went OK which make me thing it
> is a new "feature" in the recent versions of gcc.
>
> Is there a way to turn off this "optimization" or whatever it is? And btw
> why is this the default behavior?
Use either of -fno-builtin-printf or -fno-builtin.
Btw. if you have a free-standing environment, use -ffree-standing,
Andreas
--
Andreas Jaeger
SuSE Labs aj at suse dot de
private aj at arthur dot inka dot de
http://www.suse.de/~aj