]> git.lyx.org Git - features.git/commitdiff
Use explicit macro to declare that we want to use C++11
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 19 May 2015 13:10:38 +0000 (15:10 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 20 May 2015 08:19:19 +0000 (10:19 +0200)
This replaces tests for __cplusplus >= 201103L, which are wrong with gcc 4.6 and earlier. Indeed these versions of gcc define __cplusplus = 1.

Reference:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=1773

config/lyxinclude.m4
src/support/bind.h
src/support/functional.h
src/support/lyxalgo.h
src/support/regex.h
src/support/shared_ptr.h

index c9cb11d424723b1f77f6b6698daf85173515a60c..ba5344a342c18c3488af53a57d5f2131894430f2 100644 (file)
@@ -159,6 +159,15 @@ 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.
+AC_DEFUN([LYX_CXX_USE_CXX11],
+[lyx_flags="$lyx_flags c++11-mode"
+ AM_CXXFLAGS="$AM_CXXFLAGS -std=$1"
+ AC_DEFINE([LYX_USE_CXX11], 1, [Define if LyX should use C++11 features])
+])
+
+
 dnl Usage: LYX_LIB_STDCXX_CXX11_ABI: set lyx_cv_lib_stdcxx_cxx11_abi to yes
 dnl        if the STL library is GNU libstdc++ and the C++11 ABI is used.
 AC_DEFUN([LYX_LIB_STDCXX_CXX11_ABI],
@@ -329,17 +338,13 @@ 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_flags="$lyx_flags c++11-mode"
-       AM_CXXFLAGS="$AM_CXXFLAGS -std=gnu++0x";;
+        LYX_CXX_USE_CXX11(gnu++0x);;
       clang)
         dnl presumably all clang version support c++11.
-        lyx_flags="$lyx_flags c++11-mode"
        dnl the deprecated-register warning is very annoying with Qt4.x right now.
-        AM_CXXFLAGS="$AM_CXXFLAGS -std=c++11 -Wno-deprecated-register";;
+        LYX_CXX_USE_CXX11(c++11 -Wno-deprecated-register);;
       *)
-       lyx_flags="$lyx_flags c++11-mode"
-       AM_CXXFLAGS="$AM_CXXFLAGS -std=gnu++11"
-       ;;
+        LYX_CXX_USE_CXX11(gnu++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 08dd71a88598b4822455775286ba896a25da875e..1449c4394a7e6569b77138743d606700a97ac0b6 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "support/functional.h"
 
-#if __cplusplus >= 201103L
+#ifdef LYX_USE_CXX11
 
 #define LYX_BIND_NS std
 
index b86551d6f609a49e2db107e1baa9f93b71660ef2..5d373d1d14b2cf4e85a0476660e0578a1207800a 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef LYX_FUNCTIONAL_H
 #define LYX_FUNCTIONAL_H
 
-#if __cplusplus >= 201103L
+#ifdef LYX_USE_CXX11
 
 #include <functional>
 #define LYX_FUNCTIONAL_NS std
index 410bf7593351c3cb6fb5df8d8c96e2811491df53..9e44838a795233bf70df36686f3d9eacea068d1a 100644 (file)
@@ -84,7 +84,7 @@ void eliminate_duplicates(C & c)
 }
 
 
-#if __cplusplus >= 201103L
+#ifdef LYX_USE_CXX11
 using std::next;
 #else
 /// Replacement of std::next for older compilers
@@ -97,7 +97,7 @@ inline It next(It i, Diff n = 1)
 #endif
 
 
-#if __cplusplus >= 201103L
+#ifdef LYX_USE_CXX11
 using std::prev;
 #else
 /// Replacement of std::prev for older compilers
index 7c64caf43210a5c93437ba3d9438e2a95397baff..dd4875e35fe587370b9f02a7832036aa3d783ec6 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef LYX_REGEXP_H
 #define LYX_REGEXP_H
 
-#if __cplusplus >= 201103L && defined(LYX_USE_STD_REGEX)
+#if defined(LYX_USE_CXX11) && defined(LYX_USE_STD_REGEX)
 #  include <regex>
 #  ifdef _MSC_VER
 namespace lyx {
index 04dfc501a633e45ddf16fedce1b24a587b562044..d011597a39b5823dfdf396beda80a204f9acf7da 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef LYX_SHARED_PTR_H
 #define LYX_SHARED_PTR_H
 
-#if __cplusplus >= 201103L
+#ifdef LYX_USE_CXX11
 
 #include <memory>
 #define LYX_SHAREDPTR_NS std