3 ms·
"linux" is not a keyword in the C language. It's a preprocessor macro defined in the header files shipped with Linux systems -- that's quite, quite different.
by hisham_hm 13y ago
"linux" is not a keyword in the C language. It's a preprocessor macro defined in the header files shipped with Linux systems -- that's quite, quite different.
It's there so you can guard platform-dependent code with #if linux -- that's why it's defined to a trivial non-zero value.
This kind of macro should really be named with underscores, like __linux__ but the bare linux constant has been there since the early days of Linux and they just can't remove it now.
For fun, here's a list of other OS-specific macros for platform detection:
http://sourceforge.net/p/predef/wiki/OperatingSystems/ http://sourceforge.net/p/predef/wiki/OperatingSystems/