==============================================================
C 编程语言的当前标准是 ISO/IEC 9899:2024。
更多信息请阅读 ANSI 博客:当前 C 编程语言标准——ISO/IEC 9899:2024 (C24)
C 编程语言标准 (ISO/IEC 9899:2024) [当前] - ANSI 博客
如今,C 是全球最流行的编程语言之一,广泛用于操作系统、网络驱动程序、数据库、语言解释器、工具程序以及其他多种用途。虽然它起源于 20 世纪 70 年代,但其现有的实践在标准 ANSI X3.159-1989(即 C89)中得到了统一和扩展。由于这些起源,许多人仍然将 C 语言标准称为 ANSI C。然而,C 标准在 1990 年被国际采纳,并且长期以来一直是 ISO/IEC 9899,该标准由 ISO/IEC JTC 1 开发。C 语言实践整合到国际标准中促使其与 ISO C 名称的关联。
ISO/IEC 9899:2024 规定了用 C 编程语言编写的程序的形式,并建立了对其解释的标准。根据其范围,它规定了以下内容:
请注意,ISO/IEC 9899:2024 并未指定:
该标准也不涉及程序及其数据的大小或复杂性超出特定数据处理系统容量的问题,也没有涵盖支持符合标准的实现所需的数据处理系统的全部最低要求。
ISO/IEC 9899:2024 文档分为四个主要部分:
用户应注意,由于 ISO/IEC 9899 会定期修订,新功能可能会被添加或从文档中移除。因此,某些用法可能会与未来版本冲突。
ISO/IEC 9899:2024(即 C24)是对 ISO/IEC 9899:2021(即 C18)的修订。此国际标准进行了大量修改,包括但不限于:
bool
、static_assert
、true
、false
、thread_local
等,并允许实现提供旧拼写形式的宏(以下划线开头后跟大写字母),同时定义旧关键字和新关键字作为宏以方便程序过渡。static_assert
。void
的参数列表等同对待。strftime
的月份名称格式以及集成函数(如 gmtime_r
、localtime_r
、memccpy
、strdup
、strndup
),使标准与 ISO/IEC 9945(POSIX)保持一致。DECIMAL_DIG
宏过时。__STDC_VERSION__
宏一起使用,帮助升级和移植。deprecated
:标记未来不推荐使用的实体。fallthrough
:显式标记 switch 或标签中贯穿的情况,而非意外。maybe_unused
:标记可能未被使用的实体。nodiscard
:标记当使用时,其值应在程序中以某种方式处理的实体。noreturn
:指示函数永远不会返回。reproducible
:标记函数类型,对于相同的输入始终产生可预测的输出(例如缓存数据),但调用顺序仍很重要。unsequenced
:标记函数类型,始终产生可预测的输出且不依赖其他数据(及其他相关注意事项)。u8
字符前缀以匹配 u8
字符串前缀。u8
、u
和 U
字符串分别符合 ISO/IEC 10646 中定义的 UTF-8、UTF-16 和 UTF-32 标准。mbrtoc8
和 c8rtomb
函数。constexpr
说明符,并改进了与 constexpr
存储类说明符结合使用的常量表达式的识别。typeof
和 typeof_unqual
操作以推导表达式的类型。_BitInt(N)
和 unsigned _BitInt(N)
,其中 N
可以是从 1 到 BITINT_MAXWIDTH
的整数常量表达式。int
更广范围的值表示。const
属性。#embed
尽可能忠实地嵌入二进制数据。nullptr
常量和具有明确底层表示的 nullptr_t
类型,其表示与 void*
指针相同。VA_OPT
说明符,并澄清了宏调用和参数处理的语言。此列表仅包含对标准进行的大量更改中的一半左右。用户可以在文档的附录 M 中找到 ISO/IEC 9899 的变更历史。
ISO/IEC 9899:2024 – 信息技术 – 编程语言 – C 可在 ANSI Webstore 上获取。
更多信息请阅读 ANSI 博客:当前 C 编程语言标准——ISO/IEC 9899:2024 (C24)
C 编程语言标准 (ISO/IEC 9899:2024) [当前] - ANSI 博客
=======================================================
The current standard for the programming language C is ISO/IEC 9899:2024 – Information technology – Programming languages – C.
Today, C is one of the most popular programming languages used worldwide for operating systems, network drivers, databases, language interpreters, and utilities, as well as a variety of other purposes. While it originated in the 70s, the existing practices of C were unified and expanded upon in the standard ANSI X3.159-1989, or C89. Because of these origins, many people still call the C programming language standard ANSI C. However, the C standard was adopted internationally in 1990, and it has long been ISO/IEC 9899, which is developed by ISO/IEC JTC 1. The integration of C practices into an international standard sparked its association with the name ISO C.
ISO/IEC 9899:2024 specifies the form and establishes the interpretation of programs written in the C programming language. As stated in its scope, it specifies:
Please note, however, that ISO/IEC 9899:2024 does not specify:
The standard also doesn’t address the size or complexity of a program and its data that will exceed the capacity of any specific data-processing system, nor does it cover all minimal requirements of a data-processing system that is capable of supporting a conforming implementation.
The ISO/IEC 9899:2024 document is divided into four major subdivisions:
Users should note that, since ISO/IEC 9899 undergoes periodic revision, new features could be added to or withdrawn from the document. Therefore, certain uses could conflict with future editions.
ISO/IEC 9899:2024, or C24, is a revision of ISO/IEC 9899:2021, or C18. Numerous changes were made to this international standard, including:
bool
, static_assert
, true
, false
, thread_local
, and others, and implementations were allowed to provide macros for the older spelling with a leading underscore followed by a capital letter as well as defining old and new keywords as macros to enable transition of programs easily.static_assert
was added.void
.strftime
and integration of functions: gmtime_r
, localtime_r
, memccpy
, strdup
, strndup
.DECIMAL_DIG
macro was made obsolescent.__STDC_VERSION__
macro.deprecated
, for marking entities as discouraged for future usefallthrough
, for explicitly marking cases where falling through in switches or labels is intended rather than accidentalmaybe_unused
, for marking entities which can end up not being usednodiscard
, for marking entities which, when used, should have their value handled in some way by a programnoreturn
, for indicating a function shall never returnreproducible
, for marking function types for which inputs always produce predictable output if given the same input (e.g., cached data) but for which the order of such calls still mattersunsequenced
, for marking function types which always produce predictable output and have no dependencies upon other data (and other relevant caveats).u8
character prefix was added to match the u8
string prefix.u8
, u
, and U
strings were mandated to be UTF-8, UTF-16, and UTF-32, respectively, as defined by ISO/IEC 10646.mbrtoc8
and c8rtomb
functions missing were added.constexpr
specifier for object definitions was added, and the standard improved what is recognized as a constant expression in conjunction with the constexpr
storage-class specifier.typeof
and typeof_unqual
operations were added for deducing the type of an expression._BitInt(N)
and unsigned _BitInt(N)
were added, where N
can be an integer constant expression whose value is from one to BITINT_MAXWIDTH
, inclusive.int
.const
-ness of the type placed into the function.#embed
.nullptr
constant and a nullptr_t
type with a well-defined underlying representation identical to a pointer to void
were added.VA_OPT
specifier was added and language was clarified in the handling of macro invocation and arguments.This list only includes roughly half of the extensive changes made to this standard. Users can find the change history of ISO/IEC 9899 in Annex M of the document.
ISO/IEC 9899:2024 – Information technology – Programming languages – C is available on the ANSI Webstore.
Read more at the ANSI Blog: The Current C Programming Language Standard – ISO/IEC 9899:2024 (C24).