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]
Other format: [Raw text]

Re: printf optimiziation in gcc-3.2.x


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


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