Re: GCC support for C++ noexcept

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux