c - 除了不能在任何程序中使用的变量名之外,cdecl 中不允许使用哪些变量名?

标签 c identifier variable-names cdecl

我一直在玩cdecl我注意到有些名称不允许作为标识符,尽管 GCC 可以完美地编译它们。

例如,如果我写

int ptr;

int pointer;

int array;

cdecl 给出了“语法错误”,但是当我在程序中使用它时,GCC 编译它们没有任何问题。因此,有些标识符在 cdecl 中是不允许的。

哪些标识符不能在cdecl中使用,但可以在程序中使用(即程序编译)?为什么他们不被允许?

最佳答案

pointerarray 位于 cdecl 的保留关键字列表中:

char *keywords[] = {
  "function",
  "returning",
  "array",     // <--
  "pointer",   // <--
  "reference",
  "member",
  "const",
  "volatile",
  "noalias",
  "struct",
  "union",
  "enum",
  "class",
  "extern",
  "static",
  "auto",
  "register",
  "short",
  "long",
  "signed",
  "unsigned",
  "char",
  "float",
  "double",
  "void",
  NULL
};

至于ptr,我不知道为什么cdecl认为它是无效的。在 cdecl 中输入以下表达式也会失败:

declare ptr as int

但这有效:

declare ptr1 as int

很明显它也不喜欢ptr

关于c - 除了不能在任何程序中使用的变量名之外,cdecl 中不允许使用哪些变量名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29258074/

相关文章:

c - 为什么我们可以对 scanf 和 printf 使用 %d?

Oracle新手错误: ORA-00904 Invalid identifier when using "case when"

java - 使用 ID 在客户端-服务器之间发送消息 - Java

linux - 间接扩展返回变量名而不是值

javascript - JS 循环中变量的良好命名形式是什么?

language-agnostic - 您是否使用特定的约定来命名互补变量?

c - MD4 openssl 核心转储

c - 浅拷贝结构在 Xcode 上得到奇怪的结果

c - 使用移位和或操作进行缓冲操作

document - ElasticSearch ID 约束