
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; } cf., http://stackoverflow.com/questions/19210935/why-does-the-c-preprocessor-inte... -- Lev Lafayette, BA (Hons), GCertPM, MBA mobile: 0432 255 208 RFC 1855 Netiquette Guidelines http://www.ietf.org/rfc/rfc1855.txt

Lev Lafayette <lev@levlafayette.com> wrote:
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; }
It still occurs if I omit the inclusion of stdio.h, so I'd describe it as a compiler bug.

Lev Lafayette <lev@levlafayette.com> wrote:
test.c:
#include <stdio.h> int main(void) { int linux = 5; return 0; }
...
It still occurs if I omit the inclusion of stdio.h, so I'd describe it as a compiler bug.
Compilers have manifest defines that may intrude into the default namespace. It's sometimes useful in portable code Not seeing linux defines directly in the gcc -dumpspecs output though #linux $ gcc -E tmp.c # 1 "tmp.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "tmp.c" int 1 = 5; $ gcc -Ulinux -E tmp.c # 1 "tmp.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "tmp.c" int linux = 5; $ gcc -undef -E tmp.c # 1 "tmp.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "tmp.c" int linux = 5; $ gcc -v Using built-in specs. Target: powerpc-ibm-aix5.3.0.0 .... $ gcc -E tmp.c # 1 "tmp.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "tmp.c" int linux = 5;

On 2013-10-10 14:38, Jason White wrote:
rdbrown@pacific.net.au <rdbrown@pacific.net.au> wrote:
Compilers have manifest defines that may intrude into the default namespace. It's sometimes useful in portable code
Is it legitimate for them not to begin with __ however?
Has *anybody* read the Stackoverflow post? It points at the GNU GCC documentation regarding this:
$ cpp --std=c89 -dM < /dev/null | grep linux #define __linux 1 #define __linux__ 1 #define __gnu_linux__ 1
$ cpp --std=gnu89 -dM < /dev/null | grep linux #define __linux 1 #define __linux__ 1 #define __gnu_linux__ 1 #define linux 1
$ cpp --std=c99 -dM < /dev/null | grep linux #define __linux 1 #define __linux__ 1 #define __gnu_linux__ 1
$ cpp --std=gnu99 -dM < /dev/null | grep linux #define __linux 1 #define __linux__ 1 #define __gnu_linux__ 1 #define linux 1
The comment links to the last paragraph here: http://gcc.gnu.org/onlinedocs/cpp/System_002dspecific-Predefined-Macros.html... -- Regards, Matthew Cengia
participants (4)
-
Jason White
-
Lev Lafayette
-
Matthew Cengia
-
rdbrown@pacific.net.au