newlib-nano-2 icon indicating copy to clipboard operation
newlib-nano-2 copied to clipboard

printf("%llu",...)

Open vervaekejonathan opened this issue 8 years ago • 2 comments

When I use:

uint64_t nr = 123; printf("%llu", nr);

without the newlib-nano, it shows correctly 123 but when I enable newlib-nano, it shows lu

Am I missing a linker/compiler option or is this not supported in newlib-nano?

vervaekejonathan avatar Aug 25 '17 12:08 vervaekejonathan

from my experience with newlibnano in NintendoDS, you need to add SOFT VP support somehow. (I didn't care to recompile newlib nano through make config package, I recompiled everything, so it would fit my toolchain, ToolchainGenericDS)

Variadic functions is one thing (multiple arguments), to test if it works correctly, try something pretty simple as: printf("test:%x - %x",0x1234,0x5678), if you see "test:0x1234 - 0x5678" then variadic functions are working.

Then after you tested that, you need to add support for: VFP IEEE-754 compliant 64bit double / float :

https://github.com/cotodevel/newlib-nano-2/commit/cc82224b5e2ae5e463c430ab7c52370116051df4

I just tailored newlib nano for ToolchainGenericDS, so it may not be what you want, but gives an insight as of why that happens.

Also, when linking libmath, make sure the library supports your processor. I failed to run any variadic-like function from ARM7, using newlibnano (printf, sprintf failed) and that was due to that. So I had to recompile libmath, newlib nano for each processor (ARM7 and ARM9)

cotodevel avatar Dec 07 '17 14:12 cotodevel

Please note you should noto sue %lld bit the macro from stdint.h Luke

printf("%" PRIu64 "\n", ram);

MauroMombelli avatar Dec 08 '17 16:12 MauroMombelli