Bug 28314 - cpp: x86/powerpc inconsistency for the __linux macro
Summary: cpp: x86/powerpc inconsistency for the __linux macro
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-08 16:45 UTC by Debian GCC Maintainers
Modified: 2016-01-25 18:08 UTC (History)
4 users (show)

See Also:
Host:
Target: powerpc*-*-*
Build:
Known to work:
Known to fail: 4.1.2, 4.5.3, 4.8.3, 4.9.3, 5.3.0, 6.0
Last reconfirmed: 2012-01-14 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2006-07-08 16:45:46 UTC
[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
Comment 1 Andrew Pinski 2012-01-14 00:08:46 UTC
    %{!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.
Comment 2 Martin Sebor 2016-01-25 00:30:40 UTC
This hasn't changed in 10 years.  Should the bug be closed as WONTFIX?
Comment 3 Bill Schmidt 2016-01-25 15:42:52 UTC
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.
Comment 4 Vincent Lefèvre 2016-01-25 17:24:40 UTC
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.
Comment 5 Martin Sebor 2016-01-25 17:45:30 UTC
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.
Comment 6 Martin Sebor 2016-01-25 18:08:16 UTC
I opened bug 69473 to document the macros.