内部名称的前 31 或 63 个字符是否至少有意义? [关闭]

2024-01-04

以下是本书的直接引用(K&R,第二版,第 35 页):

“内部名称的至少前 31 个字符很重要。 对于函数名和外部变量,数量可能小于 31,因为外部名称可能被汇编器和加载器使用 这是语言无法控制的。对于外部名称,标准 仅保证 6 个字符和一个大小写。”

在 C99 中,其内部名称没有长度限制,但仅保证前 63 个是有效的(第 5.2.4.1 节翻译限制)。

我的问题是为什么这些限制是特别的31 or 63?为什么要特别指定这个数字呢?为什么不19, 24或任何其他数字?如果这是一个实施问题,那么实施它有什么好处吗?31 or 63?


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 http://en.wikipedia.org/wiki/Executable_and_Linkable_Format, COFF http://en.wikipedia.org/wiki/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.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

内部名称的前 31 或 63 个字符是否至少有意义? [关闭] 的相关文章

随机推荐