This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
- From: Jason Merrill <jason at redhat dot com>
- To: libstdc++ at gcc dot gnu dot org
- Cc: Marc Glisse <marc dot glisse at inria dot fr>, Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>, gcc-patches at gcc dot gnu dot org, Tom Tromey <tromey at redhat dot com>
- Date: Mon, 31 Oct 2011 13:58:12 -0400
- Subject: Re: [libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)
- References: <yddy5z2q3xt.fsf@manam.CeBiTec.Uni-Bielefeld.DE> <alpine.DEB.2.02.1108091504230.5409@laptop-mg.saclay.inria.fr> <4E419465.6080307@redhat.com> <alpine.DEB.2.02.1110212104280.6478@laptop-mg.saclay.inria.fr> <4EA1CD6C.2090308@redhat.com>
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:
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)