什么是的&QUOT的确切作用;显著人物"在C(变量)? [英] What's the exact role of "significant characters" in C (variables)?

查看:125
本文介绍了什么是的&QUOT的确切作用;显著人物"在C(变量)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是显著字符C中的确切作用,特别是在变量的场?我已阅读的题目是<一href=\"http://stackoverflow.com/questions/1980939/kr-at-least-the-first-31-characters-of-an-internal-name-are-significant\">(K&R)至少前31个字符... ,但我真的不明白的显著字符的确切规则。我非常了解的唯一的事情是,这个主题是灭绝了,但我还需要知道!

What is the exact role of "significant characters" in C , especially in the field of variables? I have read the topic "(K&R) At Least the first 31 characters...", but I really don't understand the exact rules of significant characters. The only thing I understand well is that this subject is extinct, but I still need to know!

推荐答案

在当前的C标准,ISO / IEC 9899:2011年,部分§5.2.4.1的翻译的限制说:

In the current C standard, ISO/IEC 9899:2011, section §5.2.4.1 Translation limits says:

的执行应能够翻译和执行的至少一个程序
  包含下列限制每一个的至少一个实例: 18)

The implementation shall be able to translate and execute at least one program that contains at least one instance of every one of the following limits:18)

...结果
   - 在内部标识符或宏名63显著初始字符(每
  通用字符名称或扩展源字符被认为是一个单一
  字符)结果
   - 在外部标识31显著初始字符(每个通用字符名
  指定的0000FFFF或更小的短标识符被认为是6个字符,每个
  通用字符名指定的00010000或更多的是一个短标识符
  考虑10个字符,而每个扩展源字符被认为是相同的
  字符对应的通用字符名的数量,如果有的话) 19)结果
  ...

...
— 63 significant initial characters in an internal identifier or a macro name (each universal character name or extended source character is considered a single character)
— 31 significant initial characters in an external identifier (each universal character name specifying a short identifier of 0000FFFF or less is considered 6 characters, each universal character name specifying a short identifier of 00010000 or more is considered 10 characters, and each extended source character is considered the same number of characters as the corresponding universal character name, if any)19)
...

18)实现应该避免强加固定的翻译限制只要有可能。结果
   19)见未来的语言方向''(6.11.3)。

18) Implementations should avoid imposing fixed translation limits whenever possible.
19) See ‘‘future language directions’’ (6.11.3).

§6.11.3外部名称结果
  ¶1的外部名称的意义限制到少于255个字符
  (考虑到每个通用字符名称或扩展源字符作为单个
  字符)是一个过时的功能,是一种让步,以现有的实现。

§6.11.3 External names
¶1 Restriction of the significance of an external name to fewer than 255 characters (considering each universal character name or extended source character as a single character) is an obsolescent feature that is a concession to existing implementations.

这意味着使用名称,这是第63个字符必须被视为由编译器不同的内显着,但如果你有足够的误导创建两个(或更多)的标识符,在不同的内部名称打交道时64 < SUP>个字符只(第63是相同的,但在一个64 字符,比方说, 1 和另一种是以Z ),那么编译器可能会合法,没有预警,对待这两个标识符是相同的。

This means that when dealing with names, internal names that are distinct within the first 63 characters must be treated as distinct by the compiler, but if you are misguided enough to create two (or more) identifiers that differ in the 64th character only (the first 63 are identical, but the 64th character in one is, say, 1 and in the other is z), then the compiler may legitimately, and without warning, treat those two identifiers as the same.

上的外部名称的限制 - 其影响接头,而不是编译器适当的名称 - 可以被限制为少至31个字符。试想一下:

The limit on external names — names which affect the linker rather than the compiler proper — may be limited to as few as 31 characters. Consider:

extern int abcdefghijkjlmnopqrstuvwxyz123456;
extern int abcdefghijkjlmnopqrstuvwxyz123457;

这两个声明可能被视为指的是同一变量如果系统(连接物)限制到了31个字符。

These two declarations may be treated as referring to the same variable if the system (linker) limits you to 31 characters.

作为未来的发展方向部分国家,超过255个短的限制是过时的,这意味着你不应该这个名字之前被限制为255个字符长。但该标准并不强制255个字符尚未极限。

As the future directions section states, any limit shorter than 255 is 'obsolescent', meaning that you should not be limited by this before names are 255 characters long. But the standard does not mandate 255 characters as the limit yet.

previous版本对名称的长度的上限更小的下限。在C89标准只规定6个字符monocase外部名称(但它被认为是一个痛苦的让步,以现有的接头),所以 STRCMP STRCMP 可能是一样的,可以 ABCDEFG abcdefz 。麻烦的部分可能已经Fortran语言;它只需支持6个字符monocase名称,因此在系统上的接头,其中Fortran语言被广泛使用并不需要支持更长的名字。

Previous editions of the standard had smaller lower bounds on the upper limits of the lengths of names. The C89 standard only mandated 6 characters monocase for external names (but it was regarded as a painful concession to existing linkers), so strcmp and StrCmp could be the same, as could abcdefg and abcdefz. Part of the trouble may have been Fortran; it only required support for 6 character monocase names, so linkers on systems where Fortran was widely used did not need to support longer names.

在C99限为一样C11。

The limits in C99 were the same as in C11.

这篇关于什么是的&QUOT的确切作用;显著人物&QUOT;在C(变量)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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