* [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
@ 2011-08-09 10:53 Rainer Orth
2011-08-09 13:48 ` Marc Glisse
0 siblings, 1 reply; 14+ messages in thread
From: Rainer Orth @ 2011-08-09 10:53 UTC (permalink / raw)
To: gcc-patches; +Cc: Tom Tromey, Jason Merrill, libstdc++
This patch achieves what all the previous ones have prepared: finally
defining __cplusplus correctly instead of the current 1. I'm uncertain
if it's already appropriate to define the C++ 2011 value yet, but I've
kept it in the patch.
Of course this patch can only go in once all the prerequisite patches
are installed.
Rainer
2011-03-07 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR libstdc++/1773
* init.c (cpp_init_builtins): Define __cplusplus 19971L for C++ 98,
201103L for C++ 0X.
diff -r f20c297198b4 libcpp/init.c
--- a/libcpp/init.c Sat Mar 12 10:48:29 2011 +0100
+++ b/libcpp/init.c Sat Mar 12 10:51:07 2011 +0100
@@ -452,8 +452,12 @@
|| CPP_OPTION (pfile, std)))
_cpp_define_builtin (pfile, "__STDC__ 1");
- if (CPP_OPTION (pfile, cplusplus))
- _cpp_define_builtin (pfile, "__cplusplus 1");
+ if (CPP_OPTION (pfile, lang) == CLK_CXX98
+ || CPP_OPTION (pfile, lang) == CLK_GNUCXX)
+ _cpp_define_builtin (pfile, "__cplusplus 199711L");
+ else if (CPP_OPTION (pfile, lang) == CLK_CXX0X
+ || CPP_OPTION (pfile, lang) == CLK_GNUCXX0X)
+ _cpp_define_builtin (pfile, "__cplusplus 201103L");
else if (CPP_OPTION (pfile, lang) == CLK_ASM)
_cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
else if (CPP_OPTION (pfile, lang) == CLK_STDC94)
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
2011-08-09 10:53 [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773) Rainer Orth
@ 2011-08-09 13:48 ` Marc Glisse
2011-08-09 21:32 ` Jason Merrill
0 siblings, 1 reply; 14+ messages in thread
From: Marc Glisse @ 2011-08-09 13:48 UTC (permalink / raw)
To: Rainer Orth; +Cc: gcc-patches, Tom Tromey, Jason Merrill, libstdc++
On Tue, 9 Aug 2011, Rainer Orth wrote:
> This patch achieves what all the previous ones have prepared: finally
> defining __cplusplus correctly instead of the current 1. I'm uncertain
> if it's already appropriate to define the C++ 2011 value yet, but I've
> kept it in the patch.
Hello,
I don't think we should define the C++ 2011 value yet. In my opinion, we
should wait until:
1) the standard is official
2) gcc implements most of it: people will want to use __cplusplus as a
test to know if they can use C++0X features, not if the compiler does some
effort to implement half of them.
(of course that policy is to be decided by g++ and libstdc++ maintainers)
--
Marc Glisse
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
2011-08-09 13:48 ` Marc Glisse
@ 2011-08-09 21:32 ` Jason Merrill
2011-08-09 23:51 ` Jason Merrill
` (3 more replies)
0 siblings, 4 replies; 14+ messages in thread
From: Jason Merrill @ 2011-08-09 21:32 UTC (permalink / raw)
To: libstdc++; +Cc: Marc Glisse, Rainer Orth, gcc-patches, Tom Tromey
On 08/09/2011 09:14 AM, Marc Glisse wrote:
> I don't think we should define the C++ 2011 value yet. In my opinion, we
> should wait until:
> 1) the standard is official
> 2) gcc implements most of it: people will want to use __cplusplus as a
> test to know if they can use C++0X features, not if the compiler does
> some effort to implement half of them.
I'm of two minds about this, but I see that clang and edg still use
199711L in C++0x mode, so let's stick with that for now.
Jason
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
2011-08-09 21:32 ` Jason Merrill
@ 2011-08-09 23:51 ` Jason Merrill
2011-08-10 13:47 ` Rainer Orth
` (2 subsequent siblings)
3 siblings, 0 replies; 14+ messages in thread
From: Jason Merrill @ 2011-08-09 23:51 UTC (permalink / raw)
To: gcc-patches; +Cc: Marc Glisse, Rainer Orth, gcc-patches, Tom Tromey
On 08/09/2011 09:14 AM, Marc Glisse wrote:
> I don't think we should define the C++ 2011 value yet. In my opinion, we
> should wait until:
> 1) the standard is official
> 2) gcc implements most of it: people will want to use __cplusplus as a
> test to know if they can use C++0X features, not if the compiler does
> some effort to implement half of them.
I'm of two minds about this, but I see that clang and edg still use
199711L in C++0x mode, so let's stick with that for now.
Jason
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
2011-08-09 21:32 ` Jason Merrill
2011-08-09 23:51 ` Jason Merrill
@ 2011-08-10 13:47 ` Rainer Orth
2011-08-10 18:29 ` Gabriel Dos Reis
2011-08-18 15:28 ` Rainer Orth
2011-10-21 19:50 ` Marc Glisse
3 siblings, 1 reply; 14+ messages in thread
From: Rainer Orth @ 2011-08-10 13:47 UTC (permalink / raw)
To: Jason Merrill; +Cc: libstdc++, Marc Glisse, gcc-patches, Tom Tromey
Jason Merrill <jason@redhat.com> writes:
> On 08/09/2011 09:14 AM, Marc Glisse wrote:
>> I don't think we should define the C++ 2011 value yet. In my opinion, we
>> should wait until:
>> 1) the standard is official
>> 2) gcc implements most of it: people will want to use __cplusplus as a
>> test to know if they can use C++0X features, not if the compiler does
>> some effort to implement half of them.
>
> I'm of two minds about this, but I see that clang and edg still use 199711L
> in C++0x mode, so let's stick with that for now.
Ok, I just wanted to bring it up. I'll resubmit with the 201103L change
removed once the other patches (tm etc. mangling and libstdc++) are
resolved.
Thanks.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
2011-08-10 13:47 ` Rainer Orth
@ 2011-08-10 18:29 ` Gabriel Dos Reis
0 siblings, 0 replies; 14+ messages in thread
From: Gabriel Dos Reis @ 2011-08-10 18:29 UTC (permalink / raw)
To: Rainer Orth
Cc: Jason Merrill, libstdc++, Marc Glisse, gcc-patches, Tom Tromey
On Wed, Aug 10, 2011 at 7:12 AM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
> Jason Merrill <jason@redhat.com> writes:
>
>> On 08/09/2011 09:14 AM, Marc Glisse wrote:
>>> I don't think we should define the C++ 2011 value yet. In my opinion, we
>>> should wait until:
>>> 1) the standard is official
>>> 2) gcc implements most of it: people will want to use __cplusplus as a
>>> test to know if they can use C++0X features, not if the compiler does
>>> some effort to implement half of them.
>>
>> I'm of two minds about this, but I see that clang and edg still use 199711L
>> in C++0x mode, so let's stick with that for now.
>
> Ok, I just wanted to bring it up. I'll resubmit with the 201103L change
> removed once the other patches (tm etc. mangling and libstdc++) are
> resolved.
After the experience with C++98 implementation, I have also become two-minded
about this. In the end I agree with Jason that we should just keep
the C++03 value
for the moment.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
2011-08-09 21:32 ` Jason Merrill
2011-08-09 23:51 ` Jason Merrill
2011-08-10 13:47 ` Rainer Orth
@ 2011-08-18 15:28 ` Rainer Orth
2011-08-18 20:23 ` Tom Tromey
2011-10-21 19:50 ` Marc Glisse
3 siblings, 1 reply; 14+ messages in thread
From: Rainer Orth @ 2011-08-18 15:28 UTC (permalink / raw)
To: Jason Merrill; +Cc: libstdc++, Marc Glisse, gcc-patches, Tom Tromey
[-- Attachment #1: Type: text/plain, Size: 793 bytes --]
Jason,
> On 08/09/2011 09:14 AM, Marc Glisse wrote:
>> I don't think we should define the C++ 2011 value yet. In my opinion, we
>> should wait until:
>> 1) the standard is official
>> 2) gcc implements most of it: people will want to use __cplusplus as a
>> test to know if they can use C++0X features, not if the compiler does
>> some effort to implement half of them.
>
> I'm of two minds about this, but I see that clang and edg still use 199711L
> in C++0x mode, so let's stick with that for now.
with the prerequisite patches now installed, here's the reworked version
of the final patch.
Tested as described for the rest, ok for mainline?
Rainer
2011-03-07 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR libstdc++/1773
* init.c (cpp_init_builtins): Define __cplusplus 19971L.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Correctly define __cplusplus (PR libstdc++-v3/1773) --]
[-- Type: text/x-patch, Size: 617 bytes --]
# HG changeset patch
# Parent 1751547561d4c2f04c27d9507fb5cd679c6b3eb3
Properly define __cplusplus (PR libstdc++-v3/1773)
diff --git a/libcpp/init.c b/libcpp/init.c
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -453,7 +453,7 @@ cpp_init_builtins (cpp_reader *pfile, in
_cpp_define_builtin (pfile, "__STDC__ 1");
if (CPP_OPTION (pfile, cplusplus))
- _cpp_define_builtin (pfile, "__cplusplus 1");
+ _cpp_define_builtin (pfile, "__cplusplus 199711L");
else if (CPP_OPTION (pfile, lang) == CLK_ASM)
_cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
else if (CPP_OPTION (pfile, lang) == CLK_STDC94)
[-- Attachment #3: Type: text/plain, Size: 143 bytes --]
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
2011-08-18 15:28 ` Rainer Orth
@ 2011-08-18 20:23 ` Tom Tromey
0 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2011-08-18 20:23 UTC (permalink / raw)
To: Rainer Orth; +Cc: Jason Merrill, libstdc++, Marc Glisse, gcc-patches
>>>>> "Rainer" == Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:
Jason> I'm of two minds about this, but I see that clang and edg still
Jason> use 199711L in C++0x mode, so let's stick with that for now.
Rainer> with the prerequisite patches now installed, here's the reworked version
Rainer> of the final patch.
Rainer> Tested as described for the rest, ok for mainline?
Ok.
Tom
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
2011-08-09 21:32 ` Jason Merrill
` (2 preceding siblings ...)
2011-08-18 15:28 ` Rainer Orth
@ 2011-10-21 19:50 ` Marc Glisse
2011-10-21 21:02 ` Jason Merrill
3 siblings, 1 reply; 14+ messages in thread
From: Marc Glisse @ 2011-10-21 19:50 UTC (permalink / raw)
To: Jason Merrill; +Cc: libstdc++, Rainer Orth, gcc-patches, Tom Tromey
On Tue, 9 Aug 2011, Jason Merrill wrote:
> On 08/09/2011 09:14 AM, Marc Glisse wrote:
>> I don't think we should define the C++ 2011 value yet. In my opinion, we
>> should wait until:
>> 1) the standard is official
>> 2) gcc implements most of it: people will want to use __cplusplus as a
>> test to know if they can use C++0X features, not if the compiler does
>> some effort to implement half of them.
>
> I'm of two minds about this, but I see that clang and edg still use 199711L
> in C++0x mode, so let's stick with that for now.
Note that at least clang now defines __cplusplus to its new C++11 value
(in experimental C++0X mode only). Apparently they switched around last
June and say they are not the only ones. So if you want to follow their
lead...
--
Marc Glisse
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
2011-10-21 19:50 ` Marc Glisse
@ 2011-10-21 21:02 ` Jason Merrill
2011-10-21 23:38 ` Mike Stump
2011-10-31 18:57 ` Jason Merrill
0 siblings, 2 replies; 14+ messages in thread
From: Jason Merrill @ 2011-10-21 21:02 UTC (permalink / raw)
To: libstdc++; +Cc: Marc Glisse, Rainer Orth, gcc-patches, Tom Tromey
On 10/21/2011 03:11 PM, Marc Glisse wrote:
> Note that at least clang now defines __cplusplus to its new C++11 value
> (in experimental C++0X mode only). Apparently they switched around last
> June and say they are not the only ones. So if you want to follow their
> lead...
Hmm, between that and the fact that 4.7 will in fact have almost all of
the C++11 features, I think changing the value makes sense.
Jason
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
2011-10-21 21:02 ` Jason Merrill
@ 2011-10-21 23:38 ` Mike Stump
2011-10-22 5:54 ` Jason Merrill
2011-10-22 5:54 ` Gabriel Dos Reis
2011-10-31 18:57 ` Jason Merrill
1 sibling, 2 replies; 14+ messages in thread
From: Mike Stump @ 2011-10-21 23:38 UTC (permalink / raw)
To: Jason Merrill
Cc: libstdc++, Marc Glisse, Rainer Orth, gcc-patches, Tom Tromey
On Oct 21, 2011, at 12:52 PM, Jason Merrill wrote:
> On 10/21/2011 03:11 PM, Marc Glisse wrote:
>> Note that at least clang now defines __cplusplus to its new C++11 value
>> (in experimental C++0X mode only). Apparently they switched around last
>> June and say they are not the only ones. So if you want to follow their
>> lead...
>
> Hmm, between that and the fact that 4.7 will in fact have almost all of the C++11 features, I think changing the value makes sense.
Is there a plan on what the default language will be? C is stuck in 1980, and will be forever. Personally, I'd rather have g++ move up language standards by default, I'd rather make the move before 2023.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
2011-10-21 23:38 ` Mike Stump
2011-10-22 5:54 ` Jason Merrill
@ 2011-10-22 5:54 ` Gabriel Dos Reis
1 sibling, 0 replies; 14+ messages in thread
From: Gabriel Dos Reis @ 2011-10-22 5:54 UTC (permalink / raw)
To: Mike Stump
Cc: Jason Merrill, libstdc++,
Marc Glisse, Rainer Orth, gcc-patches, Tom Tromey
On Fri, Oct 21, 2011 at 5:22 PM, Mike Stump <mikestump@comcast.net> wrote:
> On Oct 21, 2011, at 12:52 PM, Jason Merrill wrote:
>> On 10/21/2011 03:11 PM, Marc Glisse wrote:
>>> Note that at least clang now defines __cplusplus to its new C++11 value
>>> (in experimental C++0X mode only). Apparently they switched around last
>>> June and say they are not the only ones. So if you want to follow their
>>> lead...
>>
>> Hmm, between that and the fact that 4.7 will in fact have almost all of the C++11 features, I think changing the value makes sense.
>
> Is there a plan on what the default language will be? C is stuck in 1980, and will be forever. Personally, I'd rather have g++ move up language standards by default, I'd rather make the move before 2023.
I would like to see the default change too. But for GCC-4.8 -- so that should
take care of Mike's worry :-)
Do we have a formal way to announce default change in upcoming release?
I think that would give enough "heads up", especially since C++11 with break ABI
compatibilty.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
2011-10-21 23:38 ` Mike Stump
@ 2011-10-22 5:54 ` Jason Merrill
2011-10-22 5:54 ` Gabriel Dos Reis
1 sibling, 0 replies; 14+ messages in thread
From: Jason Merrill @ 2011-10-22 5:54 UTC (permalink / raw)
To: Mike Stump; +Cc: libstdc++, Marc Glisse, Rainer Orth, gcc-patches, Tom Tromey
On 10/21/2011 06:22 PM, Mike Stump wrote:
> Is there a plan on what the default language will be? C is stuck in 1980, and will be forever. Personally, I'd rather have g++ move up language standards by default, I'd rather make the move before 2023.
I think it makes sense to change the default once C++11 support is
mature, I'd guess in 4.9.
Jason
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
2011-10-21 21:02 ` Jason Merrill
2011-10-21 23:38 ` Mike Stump
@ 2011-10-31 18:57 ` Jason Merrill
1 sibling, 0 replies; 14+ messages in thread
From: Jason Merrill @ 2011-10-31 18:57 UTC (permalink / raw)
To: libstdc++; +Cc: Marc Glisse, Rainer Orth, gcc-patches, Tom Tromey
[-- Attachment #1: Type: text/plain, Size: 472 bytes --]
On 10/21/2011 03:52 PM, Jason Merrill wrote:
> On 10/21/2011 03:11 PM, Marc Glisse wrote:
>> Note that at least clang now defines __cplusplus to its new C++11 value
>> (in experimental C++0X mode only). Apparently they switched around last
>> June and say they are not the only ones. So if you want to follow their
>> lead...
>
> Hmm, between that and the fact that 4.7 will in fact have almost all of
> the C++11 features, I think changing the value makes sense.
Thus:
[-- Attachment #2: 1773.patch --]
[-- Type: text/x-patch, Size: 931 bytes --]
commit f6f3e056eac1f9bcdc2ba0459723665dafd57396
Author: Jason Merrill <jason@redhat.com>
Date: Mon Oct 31 11:26:25 2011 -0400
PR libstdc++/1773
* init.c (cpp_init_builtins): Set __cplusplus for C++11.
diff --git a/libcpp/init.c b/libcpp/init.c
index bbaa8ae..9101b34 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -461,7 +461,13 @@ cpp_init_builtins (cpp_reader *pfile, int hosted)
_cpp_define_builtin (pfile, "__STDC__ 1");
if (CPP_OPTION (pfile, cplusplus))
- _cpp_define_builtin (pfile, "__cplusplus 199711L");
+ {
+ if (CPP_OPTION (pfile, lang) == CLK_CXX11
+ || CPP_OPTION (pfile, lang) == CLK_GNUCXX11)
+ _cpp_define_builtin (pfile, "__cplusplus 201103L");
+ else
+ _cpp_define_builtin (pfile, "__cplusplus 199711L");
+ }
else if (CPP_OPTION (pfile, lang) == CLK_ASM)
_cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
else if (CPP_OPTION (pfile, lang) == CLK_STDC94)
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2011-10-31 17:58 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-09 10:53 [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773) Rainer Orth
2011-08-09 13:48 ` Marc Glisse
2011-08-09 21:32 ` Jason Merrill
2011-08-09 23:51 ` Jason Merrill
2011-08-10 13:47 ` Rainer Orth
2011-08-10 18:29 ` Gabriel Dos Reis
2011-08-18 15:28 ` Rainer Orth
2011-08-18 20:23 ` Tom Tromey
2011-10-21 19:50 ` Marc Glisse
2011-10-21 21:02 ` Jason Merrill
2011-10-21 23:38 ` Mike Stump
2011-10-22 5:54 ` Jason Merrill
2011-10-22 5:54 ` Gabriel Dos Reis
2011-10-31 18:57 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).