-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Labels
Description
Our printf submodule can be configured to be much smaller by e.g., disabling a few features. Like so:
# Configure library to be as small as possible
set(SUPPORT_DECIMAL_SPECIFIERS false)
set(SUPPORT_EXPONENTIAL_SPECIFIERS false)
set(SUPPORT_MSVC_STYLE_INTEGER_SPECIFIERS false)
set(SUPPORT_WRITEBACK_SPECIFIER false)
set(SUPPORT_LONG_LONG false)
set(CHECK_FOR_NUL_IN_FORMAT_SPECIFIER false)
When SUPPORT_LONG_LONG is false, something like this will print 0.
uint64_t my_var = 99;
printf("My variable is: %lli\n", my_var);
The problem is that the compiler seems to interfere and automatically insert %lli in cases where the variable is 64 bits. E.g., if the user writes this, it will still print 0.
uint64_t my_var = 99;
printf("My variable is: %li\n", my_var);
The compiler does generate a warning, but I assume this can be a bit confusing still.
So a solution is either to keep SUPPORT_LONG_LONG on always (will increase code size) or see if it is possible to disable the compiler replacement.