]> git.lyx.org Git - features.git/blobdiff - acinclude.m4
some changes to get fewer warnings when using strict ansi compilers
[features.git] / acinclude.m4
index d48ed86ae9e42c11e34ffdaa1fc02cdfc42d46c9..00a7fc73d993f1b75086c4d17ab7af8e89886468 100644 (file)
@@ -185,9 +185,7 @@ dnl Check the version of g++
     CXXFLAGS="$lyx_opt"
   fi
   if test $with_warnings = yes ; then
-    CXXFLAGS="$CXXFLAGS -ansi -Wall"
-    # a small hack to avoid problems with headers
-    echo '#undef __STRICT_ANSI__' >>confdefs.h
+    CXXFLAGS="$CXXFLAGS -ansi -pedantic -Wall"
   fi
 else
   GXX=
@@ -195,28 +193,6 @@ else
 fi
 ])dnl
 
-dnl We do not use this one anymore.
-dnl AC_DEFUN(LYX_GXX_STRENGTH_REDUCE,[
-dnl #check for the strength reduction bug of gcc
-dnl if test x$GXX = xyes && test $cross_compiling = no ; then
-dnl   AC_CACHE_CHECK( "for gcc strength-reduce bug", ac_cv_c_gcc_strength_bug,
-dnl                   AC_TRY_RUN([
-dnl int main(void) {
-dnl   static int Array[[3]];
-dnl   unsigned int B = 3;
-dnl   int i;
-dnl   for(i=0; i<B; i++) Array[[i]] = i - 3;
-dnl   exit( Array[[1]] != -2 );
-dnl }],
-dnl     ac_cv_c_gcc_strength_bug="no",
-dnl     ac_cv_c_gcc_strength_bug="yes",
-dnl     ac_cv_c_gcc_strength_bug="yes") )
-dnl   if test "$ac_cv_c_gcc_strength_bug" = "yes"
-dnl   then
-dnl     CXXFLAGS="$CXXFLAGS -fno-strength-reduce"
-dnl   fi
-dnl fi
-dnl ])dnl
 
 dnl Usage: LYX_CXX_RTTI : checks whether the C++ compiler
 dnl   supports RTTI
@@ -281,6 +257,7 @@ AC_DEFUN(LYX_CXX_STL_STACK,[
 AC_CACHE_CHECK(for broken STL stack template,lyx_cv_broken_stack,
  [AC_TRY_COMPILE([
 #include <stack>
+using std::stack;
 ],[
     stack<int> stakk;
     stakk.push(0);
@@ -293,19 +270,57 @@ if test $lyx_cv_broken_stack = yes ; then
 fi])
 
 
+dnl Usage: LYX_CXX_STL_MODERN_STREAMS : checks whether the C++ compiler
+dnl   supports modern STL streams
+AC_DEFUN(LYX_CXX_STL_MODERN_STREAMS,[
+AC_CACHE_CHECK(for modern STL streams,lyx_cv_modern_streams,
+ [AC_TRY_COMPILE([
+#include <fstream>
+],[
+ std::streambuf * test = std::cerr.rdbuf();
+ test->pubsync();
+],lyx_cv_modern_streams=yes,lyx_cv_modern_streams=no)
+])
+if test $lyx_cv_modern_streams = yes ; then
+  AC_DEFINE(MODERN_STL_STREAMS, 1, 
+   [Define if you have modern standard-compliant STL streams])
+fi])
+
+
 dnl Usage: LYX_CXX_STL_STRING : checks whether the C++ compiler
-dnl   has a working stl string container
+dnl   has a working stl string container, the check is really stupid
+dnl   and could need some improvement.
 AC_DEFUN(LYX_CXX_STL_STRING,[
-AC_ARG_WITH(included-string,
-[  --with-included-string  use LyX string class instead of STL string],,
-[AC_CHECK_HEADER(std/bastring.h,
-  [with_included_string=yes],
-  [with_included_string=no])])
-if test x$with_included_string = xyes ; then
-  AC_DEFINE(USE_INCLUDED_STRING, 1, 
-    [Define to use the LString class bundled with LyX])
-  lyx_flags="$lyx_flags included-string"
-fi])
+    AC_REQUIRE([LYX_PROG_CXX])
+    AC_MSG_CHECKING(whether the included std::string should be used)
+    AC_ARG_WITH(included-string,[
+       --with-included-string  use LyX string class instead of STL string
+    ],[
+       with_included_string=$withval
+    ],[
+       AC_TRY_COMPILE([
+           #include <string>
+           using std::string;
+       ],[
+           string a("hello there");
+           a.clear();
+           a = "hey";
+           a.erase();
+       ],[
+           with_included_string=no
+       ],[
+           with_included_string=yes
+           
+       ])
+    ])
+    if test x$with_included_string = xyes ; then
+       AC_DEFINE(USE_INCLUDED_STRING, 1,
+           [Define to use the lyxstring class bundled with LyX.])
+           lyx_flags="$lyx_flags included-string"
+    fi
+    AM_CONDITIONAL(USE_LYXSTRING, test x$with_included_string = xyes)
+    AC_MSG_RESULT([$with_included_string])
+])
 
 
 dnl LYX_CXX_MUTABLE
@@ -355,6 +370,7 @@ template<class T> class k<void,T> { };
 AC_MSG_RESULT([$ac_partial_specialization])
 ])
 
+
 dnl Usage: LYX_CXX_NAMESPACES : checks whether the C++ compiler
 dnl   has a correct namespace handling and define CXX_WORKING_NAMESPACES 
 dnl   if true. This macro does not do a thourough test, but it should be 
@@ -374,11 +390,13 @@ if test $lyx_cv_cxx_namespace = yes ; then
    [Define if your C++ compiler has correct support for namespaces])
 fi])
 
+
 dnl Usage: LYX_CXX_CHEADERS : checks whether the C++ compiler
 dnl   provides wrappers for C headers and use our alternate version otherwise.
 AC_DEFUN(LYX_CXX_CHEADERS,[
 AC_CACHE_CHECK(for C headers wrappers,lyx_cv_cxx_cheaders,
  [AC_TRY_CPP([
+#include <clocale>
 #include <cctype>
 #include <cerrno>
 #include <cmath>
@@ -618,6 +636,7 @@ AC_DEFUN(AC_VALIDATE_CACHE_SYSTEM_TYPE, [
     ac_cv_target_system_type="$target"
 ])
 
+
 dnl We use this until autoconf fixes its version.
 AC_DEFUN(LYX_FUNC_SELECT_ARGTYPES,
 [AC_MSG_CHECKING([types of arguments for select()])