I'm seeing that bare-arm and qemu-arm platforms use uint32_t and "%lu" which would only make sense if uint32_t is defined as an unsigned long. I thought the Cortex-M was a 32-bit platform (and therefore uses 32-bit integers), which would mean that "%lu" is potentially the wrong format to use when printing the value of an mp_uint_t variable. Unless both "unsigned" and "unsigned long" are 32 bits, in which case "%u" would work just as well as "%lu".
I would expect to see "%lu" for a 16-bit platform where unsigned is 16 bits, pointers are 32 bits and mp_uint_t is therefore an unsigned long.
I was planning to just use macros and types from inttypes.h and stdint.h as follows (and which should work for POSIX platforms). Is this safe, or have I misunderstood the purpose of these macros/types?
Code: Select all
#define UINT_FMT "%" PRIuPTR // printf specifier for mp_uint_t #define INT_FMT "%" PRIdPTR // printf specifier for mp_int_t typedef intptr_t mp_int_t; // signed integer same size as a pointer typedef uintptr_t mp_uint_t; // unsigned integer same size as a pointer