Why does the C preprocessor interpret the word "linux" as the constant "1"?
Asked 07 September, 2021
Viewed 1.3K times
  • 62
Votes

Why does the C preprocessor in GCC interpret the word linux (small letters) as the constant 1?

test.c:

#include <stdio.h>
int main(void)
{       
    int linux = 5;
    return 0;
}

Result of $ gcc -E test.c (stop after the preprocessing stage):

....
int main(void)
{
    int 1 = 5;
    return 0;
}

Which of course yields an error.

(BTW: There is no #define linux in the stdio.h file.)

5 Answer