Description
Is your enhancement proposal related to a problem? Please describe.
Zephyr currently overrides the toolchain default C99 integer types ([u]intN_t
) to fixed types such that int32_t
can always be processed without a size modifier, and int64_t
with ll
size modifier.
This "hack," introduced in #16645, has caused various toolchain compatibility issues (e.g. #37712 (comment)) and will not be sustainable as we start adding more non-GNU toolchains as supported toolchains for Zephyr -- note that __INT32_TYPE__
and its friends defined by zephyr_stdint.h
are non-standard and the toolchain default C library is not obliged to set up the type system using these.
Describe the solution you'd like
Stop re-defining the toolchain default types (i.e. remove zephyr_stdint.h
) and always use the C99 inttypes macros with the C99 integer types; e.g.:
int32_t val;
printf("val = %d", val); /* Incorrect */
printf("val = %" PRId32, val); /* Correct */
int64_t val;
printf("val = %lld", val); /* Incorrect */
printf("val = %" PRId64, val); /* Correct */
For this, the following changes need to be implemented:
- Rework the minimal libc
inttypes.h
to not assume the fixed types defined byzephyr_stdint.h
; the size modifiers need to be resolved based on the native toolchain types. - Fix all discrete size modifier used with the C99 integer types to use the C99 inttypes macros.
- Remove
zephyr_stdint.h
.
Additional context
It may be useful to go over the following related issues:
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Status