BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #40708同步于 2010/6/24
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

请教一个C的概念问题

chirky
2010/6/24镜像同步3 回复
在K&R C程序语言设计(中文版)中的P27 看到这样一句话:对于外部名而言,ANSI标准仅保证前6个字符的唯一性,而且不区分大小写。 这里的外部名是指的什么? 应该不是外部变量名吧?
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复
DrJan机器人#1 · 2010/6/24
google关键字 “外部名 6字符” 结果如下: 2.2.1 标识符命名 在C语言中,标识符是对变量、函数标号和其它各种用户定义对象的命名。标识符的长度可以是一个或多个字符。绝大多数情况下,标识符的第一个字符必须是字母或下划线,随后的字符必须是字母、数字或下划线(某些C语言编译器可能不允许下划线作为标识符的起始字符)。下面是一些正确或错误标识符命名的实例。 正确形式 错误形式 count 2count test23 hi!there high_balance high..balance A N S I标准规定,标识符可以为任意长度,但外部名必须至少能由前8个字符唯一地区分。这里外部名指的是在链接过程中所涉及的标识符,其中包括文件间共享的函数名和全局变量名。这是因为对某些仅能识别前8个字符的编译程序而言,下面的外部名将被当作同一个标识符处理。 counters counters1 counters2 A N S I标准还规定内部名必须至少能由前3 1个字符唯一地区分。内部名指的是仅出现于定义该标识符的文件中的那些标识符。C语言中的字母是有大小写区别的,因此count Count COUNT是三个不同的标识符。标识符不能和C语言的关键字相同,也不能和用户已编制的函数或C语言库函数同名。 这类问题可以先问google
chirky机器人#2 · 2010/6/24
百度之,无果,就放弃Google之。受教!
xudonglee机器人#3 · 2010/6/26
在《C专家编程》中关于外部名字也有相关记载: In practice, the ANSI C committee members were quite cautious about extending C—arguably too cautious. The Rationale shows how they agonized over whether or not they could remove the existing six-character case-insensitive limitation on the significance of external names. In the end, they decided they couldn't remove this restriction, somewhat feebly in the view of some language experts. Maybe the ANSI C committee should have bitten the bullet on this as well, and stipulated a complete solution even if it needs a pre-linker pass, instead of adopting a cockamamie partial solution from C++ with its own conventions, syntax, semantics, and limitations.