This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[libcpp] Correctly define __cplusplus (PR libstdc++-v3/1773)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]