The current implementation unconditionally includes the standard header file <stdint.h>. While this is valid for C99 and later standards, some toolchains, such as IAR Embedded Workbench configured for C89/C90 compliance, may not provide this header, resulting in compilation errors.
To improve compatibility with older C language standards while preserving existing functionality, the inclusion of <stdint.h> should be conditioned on the detected language standard.
Current Code
Proposed Fix
#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
/* C89/C90 mode: Define standard integer types locally */
#else
/* C99 and later: Use standard stdint.h */
#include <stdint.h>
#endif
Rationale
<stdint.h> is part of the C99 standard and is not guaranteed to be available when compiling in C89/C90 mode. The proposed change allows the code to compile in both C89/C90 and C99+ environments by only including <stdint.h> when the language standard supports it.
Expected Benefit
- Improved compatibility with C89/C90 toolchains, including IAR Embedded Workbench.
- No functional impact on existing C99 and newer builds.
- Better portability across different compiler configurations.
cmsis-core/CMSIS/Core/Include/cmsis_compiler.h
Line 26 in afc5ca6
The current implementation unconditionally includes the standard header file <stdint.h>. While this is valid for C99 and later standards, some toolchains, such as IAR Embedded Workbench configured for C89/C90 compliance, may not provide this header, resulting in compilation errors.
To improve compatibility with older C language standards while preserving existing functionality, the inclusion of <stdint.h> should be conditioned on the detected language standard.
Current Code
Proposed Fix
Rationale
<stdint.h> is part of the C99 standard and is not guaranteed to be available when compiling in C89/C90 mode. The proposed change allows the code to compile in both C89/C90 and C99+ environments by only including <stdint.h> when the language standard supports it.
Expected Benefit