avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Problems with float numbers


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Problems with float numbers
Date: Wed, 29 Jun 2005 15:14:18 +0200 (MET DST)

Jose Javier Segura Juarez <address@hidden> wrote:

> lcd is a pointer to an object controlling a 2x16 character lcd.
> The problem is that lcd prints ? instead 1.0.

That means you aren't using the floating-point version of printf.

> I linked math and printf_flt librabries but the problem persist.

Did you do it the way it's described in the docs?  Unless you
explicitly call vfprintf() in your application (this is the main
central function of the printf suite), you need to force the linker to
get an undefined reference to it so it will pick that one up from the
printf_flt library.  This is done by the -u option of the linker.
When passing linker options from the compiler, prepend them with -Wl,
so in total, the compiler options for floating point printf support
look like:

-Wl,-u,vfprintf -lprintf_flt

If you don't do it that way, the linker has no reason to use anything
from libprintf_flt.a, as your application only causes an undefined
reference to sprintf, that one gets resolved by the standard libc.a,
and only then another undefined reference to vfprintf will appear
which then will be resolved using libc.a again.

-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]