至少有一个内部名称的第一个31或63个字符是显著? [英] At least the first 31 or 63 characters of an internal name are significant?

查看:475
本文介绍了至少有一个内部名称的第一个31或63个字符是显著?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是从书直接引用(K&安培; R,第二版,第35页。):

Here's a direct quote from the Book (K&R, 2nd ed, p. 35):

至少一个内部名称的前31个字符是显著。
  对函数名和外部变量的数目可以是小于
  31,因为外部名称可以通过在装配和装载机使用
  该语言没有控制权。对于外部名称,标​​准
  保证只为6个字符和一个单一的情况下。

"At least the first 31 characters of an internal name are significant. For function names and external variables, the number may be less than 31, because external names may be used by assemblers and loaders over which the language has no control. For external names, the standard guarantees only for 6 characters and a single case."

和C99中有在其内的名称没有长度的限制,但是仅在第63保证是显著(§5.2.4.1翻译限值)。

And in C99 there is no length limitation on its internal names, but only the first 63 are guaranteed to be significant (§5.2.4.1 Translation Limits).

我的问题是,为什么这些限制专门的 31 63 ?为什么这个数字特别?为什么不 19,24 或任何其他数字?如果它是一个执行问题,有没有从使它成为一个利益的 31 63

My question is why are these limits specifically 31 or 63? Why this number specifically? Why not 19, 24 or any other number? If it's an implementation issue, is there a benefit from making it 31 or 63?

推荐答案

用语言设计委员会相关,通常实施某种限制,以便他们可以在工具链的实施或附图二进制文件做出假设的编译器/连接作家格式(例如, ELF COFF 等)。数字31和63很可能选择仅仅因为他们是2 N -1和程序员喜欢2 N 一些愚蠢的理由。 -1通常要占到无论是领先的在名称_ 或尾随 NUL 字符。

The compiler/linker writers associated with a language design committee usually impose some limits so that they can make assumptions in the implementation of the toolchain or in the accompanying binary file formats (e.g., ELF, COFF, etc). The numbers 31 and 63 were probably chosen simply because they are 2n-1 and programmers like 2n for some silly reason. The -1 is usually to account for either a leading _ or a trailing NUL character in the name.

这篇关于至少有一个内部名称的第一个31或63个字符是显著?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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