是编译器允许函数添加到标准头? [英] Is a compiler allowed to add functions to standard headers?

查看:98
本文介绍了是编译器允许函数添加到标准头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

允许函数添加到标准的头,仍然符合C标准C编译器?

Is a C compiler allowed to add functions to standard headers and still conform to the C standard?

我看了这个地方,但我找不到标准的任何引用,除了在附件J.5:

I read this somewhere, but I can't find any reference in the standard, except in annex J.5:

任一分机列入可能导致严格遵循规则
  程序变得无效渲染的实施不合格。
  这些扩展的例子是新的关键字,额外的库函数
  在申报标准头文件
或predefined宏与做名字
  不以下划线开头。

The inclusion of any extension that may cause a strictly conforming program to become invalid renders an implementation nonconforming. Examples of such extensions are new keywords, extra library functions declared in standard headers, or predefined macros with names that do not begin with an underscore.

不过,附件J是资料不规范的...所以它是没有帮助。

However, Annex J is informative and not normative... so it isn't helping.

所以我想如果这是正确的,或者不是一个符合编译器中添加标准头附加功能?

So I wonder if it is okay or not for a conforming compiler to add additional functions in standard headers?

举例来说,可以说是增加了非标itoa到STDLIB.H。

For example, lets say it adds non-standard itoa to stdlib.h.

推荐答案

在4一致性§6,有:

一个符合标准的实现可以有扩展(含追加
  库函数),只要它们不改变的任何行为严格符合
  程序。

A conforming implementation may have extensions (including additional library functions), provided they do not alter the behavior of any strictly conforming program.

在脚注眼前的结论是:

这意味着一个符合标准的实现储备并不比其他明确标识
  本标准保留。

This implies that a conforming implementation reserves no identifiers other than those explicitly reserved in this International Standard.

保留的标识符在7.1.3描述。基本上,它就是一切以下划线开头,一切都明确列为用于标准库。

The reserved identifiers are described in 7.1.3. Basically, it is everything starting with an underscore and everything explicitly listed as used for the standard libraries.

所以,是的编译器被允许添加扩展。但它们必须有以下划线开头或图书馆保留的prefixes的一个名字。

So, yes the compiler is allowed to add extensions. But they have to have a name starting with an underscore or one of the prefixes reserved for libraries.

itoa 不是保留标识符和编译器在一个标准的头定义它是不符合。

itoa is not a reserved identifier and a compiler defining it in a standard header is not conforming.

这篇关于是编译器允许函数添加到标准头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆