I'm willing to print a size_t
value using the %zu
format specifier in my format string, however, I always get "zu" as an output, rather than the actual value in my size_t
variable:
size_t val = 10;
printf("val: %zu\n", val); // outputs "zu", not "10"
I've seen that for other people that faced a similar issue, the fix was to set the C standard to C99 or above.
I'm building my project with CMake, and I have the following line in it:
# Set the C standard to C11
set(CMAKE_C_STANDARD 11)
So, I'd assume that I'm good to go, but no, I'm still getting the same issue.
Could I be missing something?
I'm using the following stack:
- CMake version 3.22
- Cross compiling with the arm-none-eabi-gcc version 10.3.1 toolchain
- compilation flags:
-Os -g -ffunction-sections -fdata-sections -fno-common -fmessage-length=0 -mcpu=cortex-m4 -mthumb -mthumb-interwork -mlittle-endian -mfloat-abi=hard -mfpu=fpv4-sp-d16
I've also added the -std=c11
compilation option just in case. Still does not work.