为啥"$$"也能当标识符

2022-10-25 09:44:55 +08:00
 MoRanjiang
昨天做作业碰到的。
看各种资料都只说大小写字母下划线和数字,但是 GCC 编译了确实能跑。
1969 次点击
所在节点    C
3 条回复
Shatyuka
2022-10-25 09:55:08 +08:00
gcc 方言
FrankHB
2022-10-25 21:19:47 +08:00
登记在册的已知扩展。

ISO/IEC 9899 (反正好几个版本没改了)

J.5 Common extensions
1 The following extensions are widely used in many systems, but are not portable to all implementations. 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.5.2 Specialized identifiers
1 Characters other than the underscore _, letters, and digits, that are not part of the basic source character set (such as the dollar sign $, or characters in national character sets) may appear in an identifier (6.4.2).

原则上这个是“常见”的,比如并列的有:
J.5.3 Lengths and cases of identifiers
1 All characters in identifiers (with or without external linkage) are significant (6.4.2).
类似 C89 用 6 个字符以上的标识符都算。(虽然 C99 是 31 个。)
weiweiwitch
2022-10-26 07:09:51 +08:00
你这是对钱有意见?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/889580

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX