V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
MoRanjiang
V2EX  ›  C

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

  •  
  •   MoRanjiang · 2022-10-25 09:44:55 +08:00 · 2117 次点击
    这是一个创建于 759 天前的主题,其中的信息可能已经有所发展或是发生改变。
    昨天做作业碰到的。
    看各种资料都只说大小写字母下划线和数字,但是 GCC 编译了确实能跑。
    3 条回复    2022-10-26 07:09:51 +08:00
    Shatyuka
        1
    Shatyuka  
       2022-10-25 09:55:08 +08:00 via iPhone
    gcc 方言
    FrankHB
        2
    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
        3
    weiweiwitch  
       2022-10-26 07:09:51 +08:00 via Android
    你这是对钱有意见?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   953 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 20:24 · PVG 04:24 · LAX 12:24 · JFK 15:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.