Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Improve C89/C90 compatibility by conditionally including <stdint.h>

未关闭
#7 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@KRASTM 已经在做这个了。

开始于 2026年8月14日。

评估

这个 Issue 还没有评估数据。

描述

cmsis enhancement

https://github.com/STMicroelectronics/cmsis-core/blob/afc5ca6af0a49232fde7eb4548dd0962d119ce14/CMSIS/Core/Include/cmsis_compiler.h#L26

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

#include <stdint.h>

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.
主要语言
C
星标
84
派生
24
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。