[Bug 1349907] Re: gcc, powerpc with C++11 standard does not define __linux
Ulrich Weigand
1349907 at bugs.launchpad.net
Tue Jul 29 15:57:20 UTC 2014
So there's two issues:
First of all, on amd64:
g++ -std=c++0x -dM -E - < /dev/null | grep linux
cc1: warning: command line option "-std=c++0x" is valid for C++/ObjC++ but not for C
#define __linux 1
#define __linux__ 1
#define __gnu_linux__ 1
#define linux 1
Note the warning? That means the -std=c++0x option is effectively
ignored. When you add e.g. -x c++, you'll get instead:
g++ -std=c++0x -dM -x c++ -E - < /dev/null | grep linux
#define __linux 1
#define __linux__ 1
#define __gnu_linux__ 1
Which is how it should be; in "standard" mode, "linux" is an identifier
reserved to user code and must not be pre-defined. However, __linux
*should* be predefined.
The second issue is that on rs6000, the linux macros are defined in a way that's different than on other platforms. This has the effect that even though we get the warning, the std=c++0x option is still considered to be in effect for the preprocessor defines. In addition, due to the bug you mention above, __linux is only defined in non-standard mode instead of always ...
However, given that this has been that way (unfortunately) on rs6000
forever, it is probably best not to rely on the presence of __linux in
standard mode, and use __linux__ instead.
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-4.9 in Ubuntu.
https://bugs.launchpad.net/bugs/1349907
Title:
gcc, powerpc with C++11 standard does not define __linux
Status in “gcc-4.9” package in Ubuntu:
Won't Fix
Bug description:
Envoking:
$ g++-4.9 -std=c++0x -dM -E - < /dev/null | grep linux
On amd64 shows:
#define __linux 1
#define __linux__ 1
#define __gnu_linux__ 1
#define linux 1
On powerpc shows:
#define __linux__ 1
#define __gnu_linux__ 1
Looks like "linux" and "__linux" defines are missing.
Dropping "-std=c++0x" on powerpc, makes it show all 4 linux defines.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.9/+bug/1349907/+subscriptions
More information about the foundations-bugs
mailing list