-dnl -------------------------------------------------------------
-dnl Check whether some backward compatibility features are disabled
-dnl Usage:
-dnl DEAL_II_CHECK_COMPAT_BLOCKER
-dnl
-dnl -------------------------------------------------------------
-AC_DEFUN(DEAL_II_CHECK_COMPAT_BLOCKER, dnl
-[
- AC_ARG_ENABLE(compat-blocker,
- [AS_HELP_STRING([--enable-compat-blocker=mapping],
- [Block functions that implicitely assume a Q1 mapping])],
- enable_compat_blocker="$enableval",
- enable_compat_blocker="")
-
- dnl Replace the comma-separated list by a space-separated one
- disable_compat=`echo $enable_compat_blocker | perl -pi -e 's/,/ /g;'`
-
- dnl Check that each entry is an allowed one
- for i in $disable_compat ; do
- case $i in
- mapping)
- AC_MSG_RESULT(Disabling backward compatibility feature: "$i")
- ;;
- *)
- AC_MSG_ERROR(Backward compatibility feature "$i" unknown)
- ;;
- esac
- done
-
- dnl Now for each known feature, either disable it or enable it.
- dnl Default is to enable. In order to have these flags in config.h,
- dnl it is necessary to AC_DEFINE them actually by name, rather than
- dnl by some loop variable, since otherwise autoheader can't generate
- dnl an entry for config.h for this variable
- for i in mapping ; do
- uppercase=`echo $i | perl -pi -e 'tr/a-z/A-Z/;'`
- if test -n "`echo $disable_compat | grep $i`" ; then
- compat_value=false
- else
- compat_value=true
- fi
-
- case $i in
- mapping)
- AC_DEFINE_UNQUOTED(DEAL_II_COMPAT_MAPPING,$compat_value,
- [Backward compatibility support for functions
- and classes that do not take an explicit
- mapping variable, but rather use a default
- Q1 mapping instead])
- ;;
-
- *)
- AC_MSG_ERROR(Backward compatibility feature "$i" unknown)
- ;;
- esac
- done
-])
-
-
-
dnl -------------------------------------------------------------
dnl On SunOS 4.x, the `getrusage' function exists, but is not declared
dnl in the respective header file `resource.h', as one would think when
-dnl -------------------------------------------------------------
-dnl On some systems (well, DEC Alphas are the only ones we know of),
-dnl gcc2.95 throws the hands in the air if it sees one of the AssertThrow
-dnl calls, and dies with an internal compiler error. If this is the case,
-dnl we disable AssertThrow and simply replace it with an `abort' if the
-dnl condition is not satisfied.
-dnl
-dnl Usage: DEAL_II_CHECK_ASSERT_THROW("description of options set",
-dnl "compiler options set",
-dnl action if compiler crashes)
-dnl
-dnl -------------------------------------------------------------
-AC_DEFUN(DEAL_II_CHECK_ASSERT_THROW, dnl
-[
- AC_MSG_CHECKING(whether AssertThrow works with $1 flags)
- AC_LANG(C++)
- CXXFLAGS="$2"
- AC_TRY_COMPILE(
- [
-#include <exception>
-#include <iostream>
-#include <cstdlib>
-
-#ifndef __GNUC__
-# define __PRETTY_FUNCTION__ "(unknown)"
-#endif
-class ExceptionBase : public std::exception {
- public:
- ExceptionBase ();
- ExceptionBase (const char* f, const int l, const char *func,
- const char* c, const char *e);
- virtual ~ExceptionBase () throw();
- void SetFields (const char *f, const int l, const char *func,
- const char *c, const char *e);
- void PrintExcData (std::ostream &out) const;
- virtual void PrintInfo (std::ostream &out) const;
- virtual const char * what () const throw ();
- protected:
- const char *file;
- unsigned int line;
- const char *function, *cond, *exc;
-};
-
-template <class exc>
-void __IssueError_Assert (const char *file,
- int line,
- const char *function,
- const char *cond,
- const char *exc_name,
- exc e){
- e.SetFields (file, line, function, cond, exc_name);
- std::cerr << "--------------------------------------------------------"
- << std::endl;
- e.PrintExcData (std::cerr);
- e.PrintInfo (std::cerr);
- std::cerr << "--------------------------------------------------------"
- << std::endl;
- std::abort ();
-}
-
-template <class exc>
-void __IssueError_Throw (const char *file,
- int line,
- const char *function,
- const char *cond,
- const char *exc_name,
- exc e) {
- // Fill the fields of the exception object
- e.SetFields (file, line, function, cond, exc_name);
- throw e;
-}
-
-#define AssertThrow(cond, exc) \
- { \
- if (!(cond)) \
- __IssueError_Throw (__FILE__, \
- __LINE__, \
- __PRETTY_FUNCTION__, #cond, #exc, exc); \
- }
-
-#define DeclException0(Exception0) \
-class Exception0 : public ExceptionBase {}
-
-namespace StandardExceptions
-{
- DeclException0 (ExcInternalError);
-}
-using namespace StandardExceptions;
- ],
- [
- AssertThrow (false, ExcInternalError());
- ],
- [
- AC_MSG_RESULT(yes)
- ],
- [
- AC_MSG_RESULT(no)
- $3
- ])
-])
-
-
dnl -------------------------------------------------------------
dnl Sun's Forte compiler (at least up to the Version 7 Early Access
])
-dnl -------------------------------------------------------------
-dnl Versions of GCC before 3.0 had a problem with the following
-dnl code:
-dnl
-dnl /* ----------------------------------------------- */
-dnl namespace NS {
-dnl template <typename T> class C {
-dnl template <typename N> friend class C;
-dnl };
-dnl };
-dnl /* ----------------------------------------------- */
-dnl
-dnl This is fixed with gcc at least in snapshots before version 3.1,
-dnl but the following bug remains:
-dnl
-dnl /* ----------------------------------------------- */
-dnl namespace NS { template <typename number> class C; };
-dnl
-dnl template <typename T> class X {
-dnl template <typename N> friend class NS::C;
-dnl };
-dnl
-dnl template class X<int>;
-dnl /* ----------------------------------------------- */
-dnl
-dnl The compiler gets an internal error for these cases. Since we need this
-dnl construct at various places, we check for it and if the compiler
-dnl dies, we use a workaround that is non-ISO C++ but works for these
-dnl compilers.
-dnl
-dnl Usage: DEAL_II_CHECK_NAMESP_TEMPL_FRIEND_BUG
-dnl
-dnl -------------------------------------------------------------
-AC_DEFUN(DEAL_II_CHECK_NAMESP_TEMPL_FRIEND_BUG, dnl
-[
- AC_MSG_CHECKING(for 1st template friend in namespace bug)
- AC_LANG(C++)
- CXXFLAGS="$CXXFLAGSG"
- AC_TRY_COMPILE(
- [
- namespace NS {
- template <typename T> class C {
- C(const C<T>&);
- template <typename N> friend class C;
- };
- }
-
- namespace NS2 { template <typename number> class C; }
-
- template <typename T> class X {
- template <typename N> friend class NS2::C;
- template <typename N> friend class NS::C;
- };
-
- template class X<int>;
-
- namespace NS {
- template<typename T>
- inline C<T>::C(const C<T>&)
- {}
- }
- ],
- [],
- [
- AC_MSG_RESULT(no)
- ],
- [
- AC_MSG_RESULT(yes. using workaround)
- AC_DEFINE_UNQUOTED(DEAL_II_NAMESP_TEMPL_FRIEND_BUG, 1,
- [Define if we have to work around a bug in gcc with
- marking all instances of a template class as friends
- to this class if the class is inside a namespace.
- See the aclocal.m4 file in the top-level directory
- for a description of this bug.])
- ])
-])
-
-
-
-dnl -------------------------------------------------------------
-dnl Another bug in gcc with template and namespaces (fixed since 3.2,
-dnl but present in 3.0):
-dnl
-dnl /* ----------------------------------------------- */
-dnl namespace NS {
-dnl template <typename> struct Foo;
-dnl }
-dnl
-dnl class Bar {
-dnl template <typename Y> friend struct NS::Foo;
-dnl };
-dnl
-dnl namespace NS {
-dnl template <typename> struct Foo { Foo (); };
-dnl }
-dnl
-dnl template struct NS::Foo<int>;
-dnl /* ----------------------------------------------- */
-dnl
-dnl gcc2.95 provides a really unhelpful error message, 3.0 gets an
-dnl internal compiler error.
-dnl
-dnl Usage: DEAL_II_CHECK_NAMESP_TEMPL_FRIEND_BUG2
-dnl
-dnl -------------------------------------------------------------
-AC_DEFUN(DEAL_II_CHECK_NAMESP_TEMPL_FRIEND_BUG2, dnl
-[
- AC_MSG_CHECKING(for 2nd template friend in namespace bug)
- AC_LANG(C++)
- CXXFLAGS="$CXXFLAGSG -Werror"
- AC_TRY_COMPILE(
- [
- namespace NS {
- template <typename> struct Foo;
- }
-
- class Bar {
- template <typename Y> friend struct NS::Foo;
- };
-
- namespace NS {
- template <typename> struct Foo { Foo (); };
- }
-
- template struct NS::Foo<int>;
- ],
- [],
- [
- AC_MSG_RESULT(no)
- ],
- [
- AC_MSG_RESULT(yes. using workaround)
- AC_DEFINE_UNQUOTED(DEAL_II_NAMESP_TEMPL_FRIEND_BUG2, 1,
- [Define if we have to work around another bug in gcc with
- marking all instances of a template class as friends
- to this class if the class is inside a namespace.
- See the aclocal.m4 file in the top-level directory
- for a description of this bug.])
- ])
-])
-
-
dnl -------------------------------------------------------------
dnl In some cases, we would like to name partial specializations
-dnl -------------------------------------------------------------
-dnl gcc 2.95 dies on this construct:
-dnl -----------------------------
-dnl template <int dim> struct TT { typedef int type; };
-dnl
-dnl template <template <int> class T> struct X {
-dnl typedef typename T<1>::type type;
-dnl void foo (type t);
-dnl };
-dnl
-dnl template <template <int> class T>
-dnl void X<T>::foo (type t) {};
-dnl
-dnl template struct X<TT>;
-dnl -----------------------------
-dnl
-dnl We work around this problem, if we encounter it.
-dnl
-dnl Usage: DEAL_II_CHECK_TEMPLATE_TEMPLATE_TYPEDEF_BUG
-dnl
-dnl -------------------------------------------------------------
-AC_DEFUN(DEAL_II_CHECK_TEMPLATE_TEMPLATE_TYPEDEF_BUG, dnl
-[
- AC_MSG_CHECKING(for template template typedef bug)
- AC_LANG(C++)
- CXXFLAGS="$CXXFLAGSG"
- AC_TRY_COMPILE(
- [
- template <int dim> struct TT { typedef int type; };
-
- template <template <int> class T> struct X {
- typedef typename T<1>::type type;
- void foo (type t);
- };
-
- template <template <int> class T>
- void X<T>::foo (type) {}
-
- template struct X<TT>;
- ],
- [],
- [
- AC_MSG_RESULT(no)
- ],
- [
- AC_MSG_RESULT(yes. using workaround)
- AC_DEFINE(DEAL_II_TEMPLATE_TEMPLATE_TYPEDEF_BUG, 1,
- [Defined if the compiler refuses to allow a typedef
- to a template template class template parameter. For
- the exact failure mode, look at aclocal.m4 in the
- top-level directory.])
- ])
-])
-
-
-
-dnl -------------------------------------------------------------
-dnl gcc 2.95 as well as some other compilers do not correctly implement
-dnl the resolution of defect report #45 to the C++ standard (see
-dnl http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_active.html#45).
-dnl try to detect this, and set a flag correspondingly. in short,
-dnl the DR says that this is allowed, since member classes are
-dnl implicitly also friends:
-dnl -----------------------------
-dnl struct X {
-dnl X ();
-dnl private:
-dnl static int f();
-dnl
-dnl struct Y {
-dnl int g() { return f(); };
-dnl };
-dnl };
-dnl -----------------------------
-dnl
-dnl We work around this problem, if we encounter it.
-dnl
-dnl Usage: DEAL_II_CHECK_NESTED_CLASS_FRIEND_BUG
-dnl
-dnl -------------------------------------------------------------
-AC_DEFUN(DEAL_II_CHECK_NESTED_CLASS_FRIEND_BUG, dnl
-[
- AC_MSG_CHECKING(for nested classes are implicit friends bug)
- AC_LANG(C++)
- CXXFLAGS="$CXXFLAGSG"
- AC_TRY_COMPILE(
- [
- struct X {
- X ();
- private:
- static int f();
-
- struct Y {
- int g() { return f(); };
- };
- };
- ],
- [],
- [
- AC_MSG_RESULT(no)
- ],
- [
- AC_MSG_RESULT(yes. using workaround)
- AC_DEFINE(DEAL_II_NESTED_CLASS_FRIEND_BUG, 1,
- [Defined if the compiler does not properly implement
- the resolution of defect report #45 to the C++
- standard, which makes nested types implicit friends
- of the enclosing class.])
- ])
-])
-
-
-
-dnl -------------------------------------------------------------
-dnl gcc up to 3.3 won't accept the following code:
-dnl -----------------------------
-dnl template <typename> class X {
-dnl template <typename> class Y {};
-dnl
-dnl template <typename T>
-dnl template <typename>
-dnl friend class X<T>::Y;
-dnl };
-dnl
-dnl X<int> x;
-dnl -----------------------------
-dnl
-dnl They don't accept the X<T>::Y here, probably because the class is
-dnl not complete at this point. gcc3.4 gets it right, though. One
-dnl can work around by simply saying
-dnl template <typename> friend class Y;
-dnl but then icc doesn't understand this :-( So everyone's got a bug
-dnl here. Also, note that the standard says that Y is an implicit friend
-dnl of X, but again, many compiler don't implement this correctly, which
-dnl is why we have to do something like the above in the first place...
-dnl
-dnl Usage: DEAL_II_CHECK_NESTED_CLASS_TEMPL_FRIEND_BUG
-dnl
-dnl -------------------------------------------------------------
-AC_DEFUN(DEAL_II_CHECK_NESTED_CLASS_TEMPL_FRIEND_BUG, dnl
-[
- AC_MSG_CHECKING(for nested template class friends bug)
- AC_LANG(C++)
- CXXFLAGS="$CXXFLAGSG"
- AC_TRY_COMPILE(
- [
- template <typename> class X {
- template <typename> class Y {};
-
- template <typename T>
- template <typename>
- friend class X<T>::Y;
- };
-
- X<int> x;
- ],
- [],
- [
- AC_MSG_RESULT(no)
- ],
- [
- AC_MSG_RESULT(yes. using workaround)
- AC_DEFINE(DEAL_II_NESTED_CLASS_TEMPL_FRIEND_BUG, 1,
- [Defined if the compiler does not understand friend
- declarations for nested member classes when giving
- a full class specification.])
- ])
-])
-
-
-
dnl -------------------------------------------------------------
dnl Many compilers get this wrong (see Section 14.7.3.1, number (4)):
dnl ---------------------------------
])
-
-dnl -------------------------------------------------------------
-dnl gcc 2.95 doesn't like it if we have a member template function
-dnl and define it as a template while specializing the outer class
-dnl template. This is a nasty bug that is hard to work around...
-dnl
-dnl Usage: DEAL_II_CHECK_MEMBER_TEMPLATE_SPECIALIZATION_BUG
-dnl
-dnl -------------------------------------------------------------
-AC_DEFUN(DEAL_II_CHECK_MEMBER_TEMPLATE_SPECIALIZATION_BUG, dnl
-[
- AC_MSG_CHECKING(for template member function specialization bug)
- AC_LANG(C++)
- CXXFLAGS="$CXXFLAGSG"
- AC_TRY_COMPILE(
- [
- template <int dim> struct X
- {
- template <typename T> void f(T);
- };
-
- template <>
- template <typename T>
- void X<1>::f (T)
- {}
-
- template void X<1>::f(int);
- ],
- [],
- [
- AC_MSG_RESULT(no)
- ],
- [
- AC_MSG_RESULT(yes. using workaround)
- AC_DEFINE(DEAL_II_MEMBER_TEMPLATE_SPECIALIZATION_BUG, 1,
- [Defined if the compiler refuses to specialize
- an outer class template while keeping a member
- as a template. For the exact failure mode, look at
- aclocal.m4 in the top-level directory.])
- ])
-])
-
-
-
-dnl -------------------------------------------------------------
-dnl gcc3.1 (and maybe later compilers) has a bug with long double
-dnl and optimization (see code below), when compiling on Sparc
-dnl machines. Since it affects only one platform and one compiler,
-dnl we take the liberty to disable the function in which the problem
-dnl occurs (Polynomial::shift in base/source/polynomial.cc), since
-dnl this is a function that is rarely used anyway.
-dnl
-dnl For more information: the bug just described is reported to
-dnl the gcc project under number 7335.
-dnl
-dnl Usage: DEAL_II_CHECK_LONG_DOUBLE_LOOP_BUG
-dnl
-dnl -------------------------------------------------------------
-AC_DEFUN(DEAL_II_CHECK_LONG_DOUBLE_LOOP_BUG, dnl
-[
- AC_MSG_CHECKING(for long double optimization bug)
- AC_LANG(C++)
- CXXFLAGS="$CXXFLAGSO"
- AC_TRY_COMPILE(
- [
- double* copy(long double* first, long double* last, double* result)
- {
- int n;
- for (n = last - first; n > 0; --n) {
- *result = *first;
- ++first;
- ++result;
- }
- return result;
- }
-
- void f()
- {
- long double *p1=0, *p2=0;
- double *p3=0;
- copy (p1, p2, p3);
- p3 = copy (p1, p2, p3);
- };
- ],
- [],
- [
- AC_MSG_RESULT(no)
- ],
- [
- AC_MSG_RESULT(yes. disabling respective functions)
- AC_DEFINE(DEAL_II_LONG_DOUBLE_LOOP_BUG, 1,
- [Defined if the compiler gets an internal compiler
- upon some code involving long doubles, and with
- optimization. For the details, look at
- aclocal.m4 in the top-level directory.])
- ])
-])
-
-
-
-dnl -------------------------------------------------------------
-dnl gcc2.95 (but not later compilers) has a bug with taking the
-dnl address of a function with template template parameters (or
-dnl with calling this function by specifying explicitly the template
-dnl arguments). This requires some working around that in turn does
-dnl not work with later compilers.
-dnl
-dnl Usage: DEAL_II_CHECK_FUNPTR_TEMPLATE_TEMPLATE_BUG
-dnl
-dnl -------------------------------------------------------------
-AC_DEFUN(DEAL_II_CHECK_FUNPTR_TEMPLATE_TEMPLATE_BUG, dnl
-[
- AC_MSG_CHECKING(for address of template template function bug)
- AC_LANG(C++)
- CXXFLAGS="$CXXFLAGSG"
- AC_TRY_COMPILE(
- [
- template <int> struct X {};
-
- template <int dim, template <int> class T>
- void f(T<dim>);
-
- template <int dim, template <int> class T>
- void* g()
- {
- void (*p) (T<dim>) = &f<dim,T>;
- return (void*)p;
- }
-
- template void* g<2,X> ();
- ],
- [],
- [
- AC_MSG_RESULT(no)
- ],
- [
- AC_MSG_RESULT(yes. using workaround)
- AC_DEFINE(DEAL_II_FUNPTR_TEMPLATE_TEMPLATE_BUG, 1,
- [Defined if the compiler needs a workaround for
- certain problems with taking the address of
- template template functions. For the details, look at
- aclocal.m4 in the top-level directory.])
- ])
-])
-
-
-
dnl -------------------------------------------------------------
dnl We compile all the files in the deal.II subdirectory multiple
dnl times, for the various space dimensions. When a program
-dnl -------------------------------------------------------------
-dnl Old versions of gcc (in particular gcc 3.3.3) has a problem
-dnl if an argument to a member function is an array with bounds
-dnl that depend on a static const variable inside that class.
-dnl
-dnl Usage: DEAL_II_CHECK_ARRAY_CONDITIONAL_DECAY_BUG
-dnl
-dnl -------------------------------------------------------------
-AC_DEFUN(DEAL_II_CHECK_ARRAY_ARG_BUG, dnl
-[
- AC_MSG_CHECKING(for array argument bug)
- AC_LANG(C++)
- CXXFLAGS="-W -Wall -Werror"
- AC_TRY_COMPILE(
- [
- template <int dim> struct X {
- static const unsigned int N = 1<<dim;
- void f(int (&)[N]);
- };
-
- template <int dim> void X<dim>::f(int (&)[N]) {}
- ],
- [
- ],
- [
- AC_MSG_RESULT(no)
- ],
- [
- AC_MSG_RESULT(yes)
- AC_DEFINE(DEAL_II_ARRAY_ARG_BUG, 1,
- [Defined if the compiler has a problem with
- using arrays as arguments in functions])
- ])
-])
-
-
-
dnl -------------------------------------------------------------
dnl Some versions of gcc get this example wrong:
dnl ---------------------------------
-dnl -------------------------------------------------------------
-dnl gcc versions up to 2.95.3 had a problem with the std::advance function,
-dnl when the number of steps forward was given by an unsigned number, since
-dnl a comparison >=0 was performed on this number which leads to a warning
-dnl that this comparison is always true. This is, at the best, annoying
-dnl since it crops up at several places where std::advance is called from
-dnl inside the library. Check whether the present version of the compiler
-dnl has this problem
-dnl
-dnl This test is only called if gcc is used.
-dnl
-dnl Usage: DEAL_II_CHECK_ADVANCE_WARNING
-dnl -------------------------------------------------------------
-AC_DEFUN(DEAL_II_CHECK_ADVANCE_WARNING, dnl
-[
- AC_MSG_CHECKING(for std::advance warning)
- AC_LANG(C++)
- CXXFLAGS="$CXXFLAGSG -Werror"
- AC_TRY_COMPILE(
- [
-#include <map>
-#include <vector>
- ],
- [
- std::map<unsigned int, double> m;
- std::vector<std::pair<unsigned int, double> > v;
- v.insert (v.end(), m.begin(), m.end());
- ],
- [
- dnl compilation succeeded, no warning occured for the above code
- AC_MSG_RESULT(no)
- DEAL_II_ADVANCE_WARNING=no
- ],
- [
- AC_MSG_RESULT(yes)
- DEAL_II_ADVANCE_WARNING=yes
- ]
- )
-])
-
-
-
-
dnl -------------------------------------------------------------
dnl On some Cygwin systems, a system header file includes this
dnl preprocessor define: