]> git.lyx.org Git - lyx.git/commitdiff
Improve detection of C++11 mode
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 3 Sep 2015 08:22:56 +0000 (10:22 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 3 Sep 2015 08:22:56 +0000 (10:22 +0200)
This replaces commit 329eae56 with a better solution. Indeed, while
__cpluplus is useless with g++ 4.[3-6] because its value is always 1,
these compilers define __GXX_EXPERIMENTAL_CXX0X__ when "-std c++0x" is used.

Therefore the code now relies on both macros to detect C++11 mode
instead of setting it when --enable-cxx11 is used.

Also, use pure c++ mode instead of gnu++ extensions on gcc

config/lyxinclude.m4
configure.ac

index dc744972e760b57be5faf2f14b500e74a8b06bbb..8aa2f7f870009c5317d5745855010f538ae1002f 100644 (file)
@@ -160,11 +160,10 @@ AC_DEFUN([LYX_LIB_STDCXX],
 
 
 dnl Usage: LYX_CXX_USE_CXX11(STD): pass option -std=STD to the C++ compiler
-dnl        and define LYX_USE_CXX11.
+dnl        and update lyxflags
 AC_DEFUN([LYX_CXX_USE_CXX11],
-[lyx_flags="$lyx_flags c++11-mode"
+[lyx_flags="$lyx_flags c++11"
  AM_CXXFLAGS="$AM_CXXFLAGS -std=$1"
- AC_DEFINE([LYX_USE_CXX11], 1, [Define if LyX should use C++11 features])
 ])
 
 
@@ -338,13 +337,15 @@ if test x$GXX = xyes; then
     case $gxx_version in
       4.0*|4.1*|4.2*) AC_ERROR([There is no C++11 support in gcc 4.2 or older]);;
       4.3*|4.4*|4.5*|4.6*)
-        LYX_CXX_USE_CXX11(gnu++0x);;
+        dnl Note that this will define __GXX_EXPERIMENTAL_CXX0X__.
+        dnl The source code relies on that.
+        LYX_CXX_USE_CXX11(c++0x);;
       clang)
         dnl presumably all clang version support c++11.
        dnl the deprecated-register warning is very annoying with Qt4.x right now.
         LYX_CXX_USE_CXX11(c++11 -Wno-deprecated-register);;
       *)
-        LYX_CXX_USE_CXX11(gnu++11);;
+        LYX_CXX_USE_CXX11(c++11);;
     esac
     if test x$CLANG = xno || test $lyx_cv_lib_stdcxx = yes; then
       dnl <regex> in gcc is unusable in versions less than 4.9.0
index eace28557a8c5ae818b9dcdb98a266f71b928868..17a463af5a6771ac076a95746ff31d4988875b6a 100644 (file)
@@ -276,6 +276,10 @@ AH_BOTTOM([
 /************************************************************
  ** You should not need to change anything beyond this point */
 
+#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
+#define LYX_USE_CXX11
+#endif
+
 #ifndef HAVE_STRERROR
 #if defined(__cplusplus)
 extern "C"