[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
build: check for C++98 and 03 like the others
From: |
Akim Demaille |
Subject: |
build: check for C++98 and 03 like the others |
Date: |
Sun, 23 Sep 2018 10:14:21 +0200 |
commit a616b8d3be6b7c1f54d62058be7debdfbf7de3c8
Author: Akim Demaille <address@hidden>
Date: Sun Sep 23 08:58:48 2018 +0200
build: check for C++98 and 03 like the others
* m4/bison-cxx-std.m4 (BISON_CXX_COMPILE_STDCXX_98)
(BISON_CXX_COMPILE_STDCXX_03): New.
* configure.ac: Use them.
diff --git a/configure.ac b/configure.ac
index 232ee8d8..0540a50a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,8 +73,8 @@ AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
AC_LANG_PUSH([C++])
gl_WARN_ADD([-fno-exceptions], [NO_EXCEPTIONS_CXXFLAGS])
-gl_WARN_ADD([-std=c++98], [CXX98_CXXFLAGS])
-gl_WARN_ADD([-std=c++03], [CXX03_CXXFLAGS])
+BISON_CXX_COMPILE_STDCXX_98
+BISON_CXX_COMPILE_STDCXX_03
BISON_CXX_COMPILE_STDCXX_11
BISON_CXX_COMPILE_STDCXX_14
BISON_CXX_COMPILE_STDCXX_17
diff --git a/m4/bison-cxx-std.m4 b/m4/bison-cxx-std.m4
index d5631caa..a0722310 100644
--- a/m4/bison-cxx-std.m4
+++ b/m4/bison-cxx-std.m4
@@ -6,13 +6,21 @@
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
+m4_define([_BISON_CXX_COMPILE_STDCXX_98_snippet],
+[#include <vector>
+
+typedef std::vector<int> ints;
+])
+
+m4_define([_BISON_CXX_COMPILE_STDCXX_03_snippet],
+[])
+
m4_define([_BISON_CXX_COMPILE_STDCXX_11_snippet],
[#include <algorithm>
#include <memory>
#include <set>
#include <sstream>
#include <string>
-#include <vector>
// C++11
template <typename T>
@@ -83,19 +91,36 @@ m4_define([_BISON_CXX_COMPILE_STDCXX_2A_snippet],
])
+m4_define([_BISON_CXX_COMPILE_STDCXX_98_testbody],
+[AC_LANG_PROGRAM([
+_BISON_CXX_COMPILE_STDCXX_98_snippet
+])])
+
+m4_define([_BISON_CXX_COMPILE_STDCXX_03_testbody],
+[AC_LANG_PROGRAM([
+_BISON_CXX_COMPILE_STDCXX_98_snippet
+_BISON_CXX_COMPILE_STDCXX_03_snippet
+])])
+
m4_define([_BISON_CXX_COMPILE_STDCXX_11_testbody],
[AC_LANG_PROGRAM([
+_BISON_CXX_COMPILE_STDCXX_98_snippet
+_BISON_CXX_COMPILE_STDCXX_03_snippet
_BISON_CXX_COMPILE_STDCXX_11_snippet
])])
m4_define([_BISON_CXX_COMPILE_STDCXX_14_testbody],
[AC_LANG_PROGRAM([
+_BISON_CXX_COMPILE_STDCXX_98_snippet
+_BISON_CXX_COMPILE_STDCXX_03_snippet
_BISON_CXX_COMPILE_STDCXX_11_snippet
_BISON_CXX_COMPILE_STDCXX_14_snippet
])])
m4_define([_BISON_CXX_COMPILE_STDCXX_17_testbody],
[AC_LANG_PROGRAM([
+_BISON_CXX_COMPILE_STDCXX_98_snippet
+_BISON_CXX_COMPILE_STDCXX_03_snippet
_BISON_CXX_COMPILE_STDCXX_11_snippet
_BISON_CXX_COMPILE_STDCXX_14_snippet
_BISON_CXX_COMPILE_STDCXX_17_snippet
@@ -103,6 +128,8 @@ _BISON_CXX_COMPILE_STDCXX_17_snippet
m4_define([_BISON_CXX_COMPILE_STDCXX_2A_testbody],
[AC_LANG_PROGRAM([
+_BISON_CXX_COMPILE_STDCXX_98_snippet
+_BISON_CXX_COMPILE_STDCXX_03_snippet
_BISON_CXX_COMPILE_STDCXX_11_snippet
_BISON_CXX_COMPILE_STDCXX_14_snippet
_BISON_CXX_COMPILE_STDCXX_17_snippet
@@ -111,6 +138,34 @@ _BISON_CXX_COMPILE_STDCXX_2A_snippet
+AC_DEFUN([BISON_CXX_COMPILE_STDCXX_98],
+[AC_REQUIRE([AC_PROG_CXX])
+AC_LANG_PUSH([C++])
+for f in '-std=c++98' '-std=c++98 -stdlib=libc++'
+do
+ BISON_CHECK_COMPILER_FLAG([$f],
+ [AC_SUBST([CXX98_CXXFLAGS], [$f]) break],
+ [], [],
+ [_BISON_CXX_COMPILE_STDCXX_98_testbody])
+done
+AC_LANG_POP([C++])
+])
+
+
+AC_DEFUN([BISON_CXX_COMPILE_STDCXX_03],
+[AC_REQUIRE([AC_PROG_CXX])
+AC_LANG_PUSH([C++])
+for f in '-std=c++03' '-std=c++03 -stdlib=libc++'
+do
+ BISON_CHECK_COMPILER_FLAG([$f],
+ [AC_SUBST([CXX03_CXXFLAGS], [$f]) break],
+ [], [],
+ [_BISON_CXX_COMPILE_STDCXX_03_testbody])
+done
+AC_LANG_POP([C++])
+])
+
+
AC_DEFUN([BISON_CXX_COMPILE_STDCXX_11],
[AC_REQUIRE([AC_PROG_CXX])
AC_LANG_PUSH([C++])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- build: check for C++98 and 03 like the others,
Akim Demaille <=