[forwarded from http://bugs.debian.org/345587] Matthias Rechecked with 4.1.2. Bug submitter writes: As shown below, the __linux macro is no longer defined when using the C99 mode on a PowerPC machine. An x86 machine does not have this behavior. This is normal for the linux macro to be no longer defined (as it is not reserved), but I do not see why it should be the case for the __linux macro. So, IMHO, the PPC should do the same as x86. powerpc: $ gcc -dM -E -xc /dev/null | grep linux #define __linux 1 #define __linux__ 1 #define __gnu_linux__ 1 #define linux 1 $ gcc -std=c99 -dM -E -xc /dev/null | grep linux #define __linux__ 1 #define __gnu_linux__ 1 x86: $ gcc -dM -E -xc /dev/null | grep linux #define __linux 1 #define __linux__ 1 #define __gnu_linux__ 1 #define linux 1 $ gcc -std=c99 -dM -E -xc /dev/null | grep linux #define __linux 1 #define __linux__ 1 #define __gnu_linux__ 1
%{!std=*:-Dunix -D__unix -Dlinux -D__linux} \ %{std=gnu*:-Dunix -D__unix -Dlinux -D__linux}}} \ This has been a bug since the introduction of the define for __linux by: r33942 | sirl | 2000-05-16 13:53:49 -0700 (Tue, 16 May 2000) | 5 lines 2000-05-16 Franz Sirl <Franz.Sirl-kernel@lauterbach.com> * sysv4.h (CPP_OS_LINUX_SPEC): Define __unix and __linux according to given options.
This hasn't changed in 10 years. Should the bug be closed as WONTFIX?
I discussed with the OP and he no longer is concerned about it, so we might as well get this one off of our books, even though it's kind of a stupid bug.
I don't know what the discussion was. Anyway, neither __linux nor __linux__ is mentioned in the GCC manual (at least for the recent versions), so that I assume that the developers should not rely on it.
FWIW, while looking into this bug I couldn't find the topic discussed in the LSB where I would expect this to be specified. I did come across a couple of sites on the web that gather this type of information. The one below says that __linux is obsolete, apparently because it doesn't conform to POSIX: http://sourceforge.net/p/predef/wiki/OperatingSystems/ In XSH section 2.2.2 The Name Space, POSIX specifies that "all identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use by the implementation." So both __linux__ and __linux should be fine. That aside, since the macros are part of the GCC public interface (and they are relied on by users) I would expect to see them documented in the GCC manual (along with other OS identification macros such as _AIX). Since, as Vincent notes, they aren't, I think a new bug should be raised for that.
I opened bug 69473 to document the macros.