scanf doesn't work
Yann E. MORIN
yann.morin.1998@anciens.enib.fr
Thu Jun 18 17:51:00 GMT 2009
On Thursday 18 June 2009 16:16:39 Leonitis wrote:
> I successfully built a cross-compiler for the ARM with crosstool-ng and
> everything works fine. However, when I want to get user float input with
> scanf(), it misses the negative sign, even though it works fine with
> integers. For example, 3.5 and -3.5 are both read in as 3.5.
Works for me with:
linux headers 2.6.29.4
gmp-4.2.4
mpfr-2.4.1
binutils-2.19.1
gcc-4.3.3
glibc-2.9 dated 2009-06-18, with the ports addon.
prompt> cat >ess.c <<_EOF_
#include <stdio.h>
#include <stdlib.h>
int main( int argc,
char** argv )
{
float f;
scanf( "%f", &f );
printf( "f='%f'", f );
if( f < 0 ) { printf( "is negative\n" ); }
else if( f > 0 ) { printf( "is positive\n" ); }
else { printf( "is null\n" ); }
return 0;
}
_EOF_
prompt> armeb-unknown-linux-gnueabi-gcc -o ess ess.c
prompt> qemu-armeb -L [...]/armeb-unknown-linux-gnueabi/sys-root/ ./ess
-3.5
f='-3.500000' is negative
prompt> qemu-armeb -L [...]/armeb-unknown-linux-gnueabi/sys-root/ ./ess
3.5
f='3.500000' is positive
prompt> qemu-armeb -L [...]/armeb-unknown-linux-gnueabi/sys-root/ ./ess
0
f='0.000000' is null
Didn't try with ARM litle endian, though...
What's your toolchain setup?
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software Designer | \ / CAMPAIGN | ___ |
| --==< ^_^ >==-- `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
`------------------------------^-------^------------------^--------------------'
--
For unsubscribe information see http://sourceware.org/lists.html#faq
More information about the crossgcc
mailing list