Is "unix" restricted keyword in C? Is "unix" restricted keyword in C? unix unix

Is "unix" restricted keyword in C?


unix is not a identifier reserved by the Standard.

If you compile with -std=c89 or -std=c99 the gcc compiler will accept the program as you expected.

From gcc manual ( https://gcc.gnu.org/onlinedocs/cpp/System-specific-Predefined-Macros.html ), the emphasis is mine.

... 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 is one of the defines the preprocessor uses in gcc to get a list of defs use

gcc -dM -E  -x c /dev/null

(-dM tells gcc to debugdump the defs -E tells it to stop after prepreocessing and -x c /dev/null tells him to pretend /dev/null is a c file)


Run your code through the preprocessor to find out what the compiler is actually seeing:

gcc -E unix.c

Then see if your variable unix is preserved or converted by the preprocessor.