为什么 gcc 不显示在变量名中使用 $ 的警告消息?

Why is gcc not showing a warning message for using $ in a variable name?

我是 C 的新手,正在从 Programming in C,第 4 版学习 C。斯蒂芬·科尚着。在第 29 页,他写道 $ 不是变量名称的有效字符。他使用的是C11标准。

我写了下面的代码

#include <stdio.h>

int main (void)
{
    int a$ = 1;

    printf ("%i", a$);

    return 0;
}

和运行它与命令gcc -std=c11 -pedantic practice.c -o practice.o && ./practice.o。我的文件名是 practice.c.

输出为1。编译器不应该给我一个使用 $ 的警告吗?对标识符使用 $ 符号不是 GCC 提供的扩展吗?

我在 Ubuntu 18.10 中使用 GCC 8.2.0。

编辑:

另外,当我使用-std=c11时,GCC 不使用GNU 扩展吗?这就是本书附录(第 497 页)中所写的内容。

虽然我在使用 -std=c89 时收到警告。

根据这个:GCC Documentation

In GNU C, you may normally use dollar signs in identifier names. This is because many traditional C implementations allow such identifiers. However, dollar signs in identifiers are not supported on a few target machines, typically because the target assembler does not allow them.

因此,$ 是有效的,但它不是一种符合 C 语言编码的方式。

您收到 -std=c89 -pedantic 的警告。 C99 及更高版本允许在标识符中使用 other implementation-defined characters