32bitmicro / newlib-nano-2

GNU General Public License v2.0
32 stars 8 forks source link

printf("%llu",...) #3

Open vervaekejonathan opened 7 years ago

vervaekejonathan commented 7 years ago

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?

cotodevel commented 6 years ago

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)

MauroMombelli commented 6 years ago

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

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