C语言标准规范C99详解

5星 · 超过95%的资源 需积分: 43 9 下载量 133 浏览量 更新于2024-07-22 收藏 1.04MB PDF 举报
"C语言规范标准_C99.pdf" C99是C语言的一个重要标准,全称为ISO/IEC 9899:1999,由国际标准化组织(ISO)和国际电工委员会(IEC)联合发布。这个标准在1999年推出,是对早期C语言标准C89(也称为ANSI C)的更新和扩展,引入了多项新的特性和改进。C99标准旨在提高代码的可移植性、可靠性和效率,同时提供了更多灵活性以适应不断发展的编程需求。 C99规范的内容分为多个部分,包括: 1. **前言**(Foreword):这部分通常包含标准制定的背景信息和目的,以及版本间的变更说明。 2. **引言**(Introduction):简述C99标准的主要目标和变化,为读者提供整体理解。 3. **范围**(Scope):明确标准适用的领域,定义了C语言的核心概念和组成部分。 4. **规范性参考**(Normative references):列出标准所依赖的其他规范或标准。 5. **术语、定义和符号**(Terms, definitions, and symbols):对标准中使用的关键术语进行定义,确保统一的理解。 6. **符合性**(Conformance):规定了程序如何符合C99标准,包括不同的符合等级和条件。 7. **环境**(Environment):详细讨论了编译和执行C程序的环境要求,如模型、字符集、显示语义、信号处理和系统限制等。 - **5.1 概念模型**(Conceptual models):描述翻译和执行环境的抽象模型。 - **5.1.1 翻译环境**(Translation environment):涵盖预处理、编译和链接阶段。 - **5.1.2 执行环境**(Execution environments):关注程序实际运行时的情况。 - **5.2 环境考虑**(Environmental considerations):涵盖了与环境相关的细节,如字符集、显示规则、中断处理和系统限制。 8. **语言**(Language):这部分详细定义了C语言的语法、语义和操作。 - **6.1 符号表示**(Notation):介绍标准中使用的符号和约定。 - **6.2 概念**(Concepts):涵盖了标识符的作用域、链接性、命名空间、对象的存储持续时间、类型及其表示方式等。 - **6.3 转换**(Conversions):描述了不同类型之间的转换规则,包括算术运算符和其他运算符。 - **6.4 词法元素**(Lexical elements):涵盖了关键字、标识符、通用字符名、常量、字符串字面量和标点符号。 9. **头文件名**(Header names):定义了标准库和用户自定义头文件的命名和用法。 C99标准中的新特性包括: - **复数数学函数**:支持复数运算。 - **变量长度数组**(Variable Length Arrays, VLA):允许在运行时动态定义数组大小。 - **类型安全的指针转换**:增强了类型检查,减少隐式转换带来的错误。 - **新的数据类型**:如`_Bool`(布尔型),`stdint.h`中的固定宽度整型。 - **内联函数**:提高了代码效率,允许函数像宏一样被展开。 - **枚举类型增强**:允许枚举值指定其类型和值。 - **预处理器增强**:如条件编译指令`#if`、`#elif`等的改进。 - **新的标准库功能**:如宽字符支持、内存管理函数、错误处理函数等。 学习C99标准对于理解和编写高质量、可移植的C代码至关重要,它可以帮助开发者遵循最佳实践,避免潜在的陷阱,并充分利用现代C语言提供的功能。
2019-01-08 上传
1 ISO (the International Organization for Standardization) and IEC (the International Electrotechnical Commission) form the specialized system for worldwide standardization. National bodies that are member of ISO or IEC participate in the development of International Standards through technical committees established by the respective org anization to deal with particular fields of technical activity. ISO and IEC technical committees collaborate in fields of mutual interest. Other international organizations, governmental and non-governmental, in liaison with ISO and IEC, also take part in the work. 2 International Standards are drafted in accordance with the rules given in the ISO/IEC Directives, Part 3. 3 In the field of information technology, ISO and IEC have established a joint technical committee, ISO/IEC JTC 1. Draft International Standards adopted by the joint technical committee are circulated to national bodies for voting. Publication as an International Standard requires approval by at least 75% of the national bodies casting a vote. 4 International Standard ISO/IEC 9899 was prepared by Joint Technical Committee ISO/IEC JTC 1, Information technology, Subcommittee SC 22, Programming languages, their environments and system software interfaces. The Working Group responsible for this standard (WG 14) maintains a site on the World Wide Web at http://www.dkuug.dk/JTC1/SC22/WG14/ containing additional information relevant to this standard such as a Rationale for many of the decisions made during its preparation and a log of Defect Reports and Responses. 5 This second edition cancels and replaces the first edition, ISO/IEC 9899:1990, as amended and corrected by ISO/IEC 9899/COR1:1994, ISO/IEC 9899/AMD1:1995, and ISO/IEC 9899/COR2:1996. Major changes from the previous edition include: — restricted character set support via digraphs and (originally specified in AMD1) — wide character library support in and (originally specified in AMD1) — more precise aliasing rules via effective type — restricted pointers — variable-length arrays