独立实施的各种 WG14 C 标准之间有什么区别?
实现以下每个不同标准的独立部分的编译器有何不同?支持所有模式所需的最少数量的模式(例如,由命令行标志指定)是多少?
- ISO/IEC 9899
- :1990 ISO/IEC 9899:1990 + ISO/IEC 9899 TCOR1
- ISO/IEC 9899:1990 + ISO/IEC 9899 TCOR1 + ISO/IEC 9899 AM1
- ISO/IEC 9899:1990 + ISO/IEC 9899 TCOR1 + ISO /IEC 9899 AM1 + ISO/IEC 9899 TCOR2
- ISO/IEC 9899:1999
- ISO/IEC 9899:1999 + ISO/IEC 9899:1999 Cor. 1:2001(E)
- ISO/IEC 9899:1999 + ISO/IEC 9899:1999 Cor. 1:2001(E) + ISO/IEC 9899:1999 Cor. 2:2004(E)
- ISO/IEC 9899:1999 + ISO/IEC 9899:1999 Cor。 1:2001(E) + ISO/IEC 9899:1999 Cor. 2:2004(E) + ISO/IEC 9899:1999 Cor. 3:2007(E)
- ISO/IEC 9899:2011
How would compilers implementing the freestanding portion of each different standard below have to differ? What would be the fewest number of modes (specified by command line flags, for example) required to support all of them?
- ISO/IEC 9899:1990
- ISO/IEC 9899:1990 + ISO/IEC 9899 TCOR1
- ISO/IEC 9899:1990 + ISO/IEC 9899 TCOR1 + ISO/IEC 9899 AM1
- ISO/IEC 9899:1990 + ISO/IEC 9899 TCOR1 + ISO/IEC 9899 AM1 + ISO/IEC 9899 TCOR2
- ISO/IEC 9899:1999
- ISO/IEC 9899:1999 + ISO/IEC 9899:1999 Cor. 1:2001(E)
- ISO/IEC 9899:1999 + ISO/IEC 9899:1999 Cor. 1:2001(E) + ISO/IEC 9899:1999 Cor. 2:2004(E)
- ISO/IEC 9899:1999 + ISO/IEC 9899:1999 Cor. 1:2001(E) + ISO/IEC 9899:1999 Cor. 2:2004(E) + ISO/IEC 9899:1999 Cor. 3:2007(E)
- ISO/IEC 9899:2011
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TC(技术勘误或技术更正)应被视为相应基本标准的一部分。因此,您实际上有 4 个可能的标准需要处理:
C90 修正案 1 为宽字符和多字节字符集添加了新的标头和函数,因此它包含真正的新标准材料。技术勘误修复了标准措辞中的问题,澄清了需要澄清的内容,并纠正了文件中的技术错误。
因此,我建议这四种模式就足够了:
-std=c90
-std=c95
-std=c99
- std=c11
或者,如果我们要注意导致 Y2K 问题的错误,那么:
-std=c1990
-std=c1995
-std=c1999
-std=c2011
(这样做的一个好处是最新标准再次拥有最高的数字! )
对于独立实现,所需的四个标头几乎没有什么区别:
在
中添加了一个额外的宏/函数
。va_copy()
C99 中的否则,主要变化发生在C99 中的核心语言 - 新类型 (
long long
)、新初始化符号和 VLA 等。从这个角度来看,AM1(C95)没有对独立实现进行任何更改(除非随后添加了二合字母),因为主要的更改是在独立实现中不需要的新标头中。托管实现面临更多问题,因为库支持在 C90 和 C99 之间进行了相当广泛的修改。
我不知道独立实现与托管实现相比有任何向后兼容性问题。在 C99 中,“隐式
int
”规则正式消失 - 您应该在使用函数之前声明它们,并且返回类型应显式为int
(因此,例如,一个简单的main()
不再正式有效;您应该编写int main()
或更好的int main(void)
或类似内容。但这些是 C90 (C95) 和 C99 之间的一般变化 - 并不是独立实现所特有的。 (是的,我知道独立实现不需要函数main()
作为起点。)如果您的代码是“好的”并且在使用之前使用原型声明或定义了函数,并且没有隐式 int 类型(强烈建议使用原型表示法定义的所有函数),那么对 C90 独立程序有利的东西也适用于 C99 或 C11。The TCs (technical corrigenda or technical corrections) should be treated as part of the corresponding base standard. So, you really have 4 possible standards to deal with:
The Amendment 1 for C90 added new headers and functions for wide character and multi-byte character sets, so it contained truly new standard material. The technical corrigenda fix issues in the standard wording, clarifying what needs to be clarified, and correcting technical errors in the document.
So, I would suggest that those four modes would be sufficient:
-std=c90
-std=c95
-std=c99
-std=c11
Or, if we are going to pay attention to the mistakes that led to the Y2K problems, then:
-std=c1990
-std=c1995
-std=c1999
-std=c2011
(One advantage of this is that the newest standard has the highest number once more!)
For freestanding implementations, there are few differences in the four headers that are required:
<stddef.h>
<limits.h>
<float.h>
<stdarg.h>
There was an extra macro/function,
va_copy()
, added to<stdarg.h>
in C99.Otherwise, the main changes occurred in the core language in C99 - things like the new types (
long long
), new initialization notations, and VLAs, and so on. From this perspective, AM1 (C95) didn't change anything for a freestanding implementation (unless digraphs were added then) because the main changes were in new headers that are not required in a freestanding implementation.Hosted implementations face many more issues because the library support was fairly extensively modified between C90 and C99.
I'm not aware of any backwards compatibility issues for freestanding as opposed to hosted implementations. With C99, the 'implicit
int
' rules are officially gone - you should declare functions before using them and the return type should be explicitlyint
(so, for example, a simplemain()
is no longer officially valid; you should writeint main()
or, better,int main(void)
or similar). But these are general changes between C90 (C95) and C99 - not peculiar to freestanding implementations. (And yes, I am aware that a freestanding implementation need not require a functionmain()
as the start point.) If your code is 'good' and has functions declared or defined with prototypes before use and no implicitint
types (and all functions defined using prototype notation would be strongly recommended), then what was good for a C90 freestanding program will work for C99 or C11.