sprintf & %zu, %PRIu64 and others

flok

Well-known member
Hello,

If I'm right, the teensy 4.1 sdk does not support e.g. %zu (for size_t) and others in sprintf.
Is there a solution for that that does not involve an #ifdef for each invocation?
 
I believe %zu is supported, but I do know that it's not supported in nanolib, used when producing a "smallest" build. (Note that it's possible to rebuild nanolib and add C99 support (includes %zu).)
 
To get around this limitation when using nanolib, I define my own macro, "PRIzu", that behaves similarly to the "PRIu32" ones. It's in a header that makes some determination based on the size of size_t. So instead of doing:
C++:
"xxx %zu yyy"

I do:
C++:
"xxx %" PRIzu " yyy"
 
To get around this limitation when using nanolib, I define my own macro, "PRIzu", that behaves similarly to the "PRIu32" ones. It's in a header that makes some determination based on the size of size_t. So instead of doing:
C++:
"xxx %zu yyy"

I do:
C++:
"xxx %" PRIzu " yyy"

Ah yeah, that works as well. Thanks!
 
Back
Top