Problem with printf and float
Jeppe Ledet-Pedersen
jledet@space.aau.dk
Mon Oct 25 19:21:00 GMT 2010
Hi everybody,
This question was originally posted on the crossgcc mailing list, but my
problem appears to be related to Newlib so I'll repost it here. My
original question can be found at
http://sourceware.org/ml/crossgcc/2010-10/msg00147.html
I have successfully compiled a toolchain for my arm7tdmi with
crosstool-NG. I use GCC 4.5.1, Newlib CVS and Binutils 2.20.1. I have
enabled the EABI and software floating point.
I can compile my codebase with no errors or warnings, but I am having
trouble when trying to use printf and siblings with floating point
values. The problem seems to stem from a mismatch between VFP and FPA
floating point formats.
With my test code (http://pastebin.com/3Dsb9siL), I get the following
output:
00 00 00 00 00 00 55 c0
a is 0.000000
00 00 55 c0 00 00 00 00
a (flipped) is -84.000000
So it appears that GCC stores the double value in correct little-endian,
VFP format but Newlib will only print it if converted to FPA format. I
have looked through the code for _vfprint_r and _dtoa_r but haven't
noticed anything suspicious. As far as I can see, everything seems correct.
If I i run "arm-unknown-eabi-cpp -dD" my toolchain defines both
__ARMEL__, __SOFTFP__ and __VFP_FP__ which should be taken into account
by Newlib in include/machine/ieeefp.h to use the correct pure little
endian floating point format.
Any advice on what could cause this behavior? If you need additional
information, just let me know.
You can see my full crosstool-NG build log at
http://kom.aau.dk/~jledet/build_vfp.log.bz2
Thank you in advance.
Best regards,
Jeppe
--
For unsubscribe information see http://sourceware.org/lists.html#faq
More information about the crossgcc
mailing list