This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: GCC support for C++ noexcept
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Edward Diener <eldlistmailingz at tropicsoft dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Mon, 27 Jul 2015 23:40:18 +0100
- Subject: Re: GCC support for C++ noexcept
- Authentication-results: sourceware.org; auth=none
- References: <CAH8yC8nchUG7WGQEkg-nD0jvG2sOCaZhmfUTxrVz7d=c7eZXmA at mail dot gmail dot com> <20150727015526 dot GB58373 at unpythonic dot net> <CAH8yC8=PJLmO+Z-4L804wqTj2o3_W93ZynyUg6Hjj27EAChyfw at mail dot gmail dot com> <mp4bdj$rcd$1 at ger dot gmane dot org> <CAH6eHdS5818Hmd6TX5dyzfw8X3Aa1CyvvgNkDQb2hKSgThMoew at mail dot gmail dot com> <mp5csf$5pa$1 at ger dot gmane dot org> <CAH6eHdQrE62neEYvk-FgQ28eSLz6p6NDqJ=_DFXPvnTUH7p_yQ at mail dot gmail dot com> <mp63vc$rui$1 at ger dot gmane dot org>
On 27 July 2015 at 21:22, Edward Diener wrote:
> On 7/27/2015 10:57 AM, Jonathan Wakely wrote:
>>
>> On 27 July 2015 at 14:48, Edward Diener wrote:
>>>
>>> On 7/27/2015 4:34 AM, Jonathan Wakely wrote:
>>>>
>>>>
>>>> On 27 July 2015 at 05:17, Edward Diener wrote:
>>>>>
>>>>>
>>>>>
>>>>> Try
>>>>>
>>>>> #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
>>>>> // C++11 is in effect
>>>>> #endif
>>>>
>>>>
>>>>
>>>>
>>>> GCC 4.8 defines __cplusplus to the correct YYYYMMDD value so this is
>>>> not necessary.
>>>>
>>>
>>> I meant it as a general solution for any version of gcc. It is what Boost
>>> config uses.
>>
>>
>> But it doesn't help if you run the preprocessor in C mode not C++,
>> since neither will be defined :-)
>
>
> How is it possible to be compiling for C++11 when running in C mode ?
>
> In other words it does work since a C++11 compile will never be defined when
> running in C mode, which is certainly what is wanted.
See the first mail in the thread, which attempted to use the
preprocessor to detect whether C++11 is supported like so:
$ g++ -std=c++11 -dM -E - < /dev/null | grep cplusplus
cc1.exe: warning: command line option '-std=c++11' is valid for
C++/ObjC++ but not for C [enabled by default]=
This is running the preprocessor in C mode. Checking for
__GXX_EXPERIMENTAL_CXX0X__ here won't help, because it's still using
the preprocessor in C mode, i.e. this still fails:
$ g++-4.4.7 -std=c++0x -dM -E - < /dev/null | egrep 'cplusplus|EXPERIMENTAL'
cc1: warning: command line option "-std=c++0x" is valid for C++/ObjC++
but not for C
Whereas this works, because it runs the preprocessor in C++ mode:
$ g++-4.4.7 -std=c++0x -dM -E -x c++ - < /dev/null | egrep
'cplusplus|EXPERIMENTAL'
#define __GXX_EXPERIMENTAL_CXX0X__ 1
#define __cplusplus 1
That's what I meant about running the preprocessor in C mode, not C++ mode.