是" UNIX"限制关键字用C? [英] is "unix" restricted keyword in C?
问题描述
这code不编译我的gcc版本4.3.2(Debian的4.3.2-1.1)
This code does not compile for me on gcc version 4.3.2 (Debian 4.3.2-1.1)
main(){
int unix;
}
我已经检查了C关键字列表和UNIX是不是其中之一。
为什么我会得到下面的错误?
I've checked the C keywords list and "unix" is not one of them. Why am I getting the following error?
unix.c:2: error: expected identifier or ‘(’ before numeric constant
别人吗?
推荐答案
UNIX
不是该标准保留的一个标识符。
unix
is not a identifier reserved by the Standard.
如果您编译 -std = C89
或 -std = C99
gcc编译器将接受该方案为你的预期。
If you compile with -std=c89
or -std=c99
the gcc compiler will accept the program as you expected.
从GCC手册( https://开头的gcc .gnu.org / onlinedocs / CPP /系统specific- predefined-Macros.html ),强调的是我的。
From gcc manual ( https://gcc.gnu.org/onlinedocs/cpp/System-specific-Predefined-Macros.html ), the emphasis is mine.
...但是,
历史上的系统特定的宏
有没有特别的preFIX名称;
例如,这是常见的发现
UNIX在Unix系统确定。对全部
如宏,GCC提供了一个并行
以两个下划线宏在加
的开始和结束。如果是UNIX
定义,__unix__也将被限定。
绝不会有两个以上的
下划线; _mips的水货
__mips __
... However, historically system-specific macros have had names with no special prefix; for instance, it is common to find unix defined on Unix systems. For all such macros, GCC provides a parallel macro with two underscores added at the beginning and the end. If unix is defined, __unix__ will be defined too. There will never be more than two underscores; the parallel of _mips is __mips__.
这篇关于是" UNIX"限制关键字用C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!