From 4628196be891f7132e5f3d59ec4d69a9604e4556 Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 29 Oct 2001 16:36:52 +0000 Subject: [PATCH] Make the test fror AssertThrow use its own code, instead of including exceptions.h, since the latter includes config.h, which is not available at the time of ./configure git-svn-id: https://svn.dealii.org/trunk@5173 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/aclocal.m4 | 70 ++++++++++++- deal.II/configure | 252 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 263 insertions(+), 59 deletions(-) diff --git a/deal.II/aclocal.m4 b/deal.II/aclocal.m4 index abe95b2544..b45eb4c0d0 100644 --- a/deal.II/aclocal.m4 +++ b/deal.II/aclocal.m4 @@ -314,7 +314,75 @@ AC_DEFUN(DEAL_II_CHECK_ASSERT_THROW, dnl CXXFLAGS=$2 AC_TRY_COMPILE( [ -#include "base/include/base/exceptions.h" +#include +#include +#include + +#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 +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 +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()); diff --git a/deal.II/configure b/deal.II/configure index 32915d7a97..7eb7bbab70 100755 --- a/deal.II/configure +++ b/deal.II/configure @@ -1813,7 +1813,75 @@ cross_compiling=$ac_cv_prog_cxx_cross #line 1814 "configure" #include "confdefs.h" -#include "base/include/base/exceptions.h" +#include +#include +#include + +#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 +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 +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; int main() { @@ -1821,7 +1889,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:1825: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1893: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t"""yes"" 1>&6 @@ -1838,7 +1906,7 @@ fi rm -f conftest* echo $ac_n "checking whether AssertThrow works with optimized flags""... $ac_c" 1>&6 -echo "configure:1842: checking whether AssertThrow works with optimized flags" >&5 +echo "configure:1910: checking whether AssertThrow works with optimized flags" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' @@ -1848,10 +1916,78 @@ cross_compiling=$ac_cv_prog_cxx_cross CXXFLAGS=$CXXFLAGSO cat > conftest.$ac_ext < +#include +#include + +#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 +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 +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; int main() { @@ -1859,7 +1995,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:1863: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1999: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t"""yes"" 1>&6 @@ -1877,7 +2013,7 @@ rm -f conftest* echo $ac_n "checking for std::vector bug""... $ac_c" 1>&6 -echo "configure:1881: checking for std::vector bug" >&5 +echo "configure:2017: checking for std::vector bug" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' @@ -1887,7 +2023,7 @@ cross_compiling=$ac_cv_prog_cxx_cross CXXFLAGS="$CXXFLAGSG" cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2047: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""no" 1>&6 @@ -1928,7 +2064,7 @@ rm -f conftest* echo $ac_n "checking for std::iterator class""... $ac_c" 1>&6 -echo "configure:1932: checking for std::iterator class" >&5 +echo "configure:2068: checking for std::iterator class" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' @@ -1938,7 +2074,7 @@ cross_compiling=$ac_cv_prog_cxx_cross CXXFLAGS="$CXXFLAGSG" cat > conftest.$ac_ext < @@ -1949,7 +2085,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:1953: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2089: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 @@ -1969,7 +2105,7 @@ fi rm -f conftest* echo $ac_n "checking for std::i/ostringstream classes""... $ac_c" 1>&6 -echo "configure:1973: checking for std::i/ostringstream classes" >&5 +echo "configure:2109: checking for std::i/ostringstream classes" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' @@ -1979,7 +2115,7 @@ cross_compiling=$ac_cv_prog_cxx_cross CXXFLAGS="$CXXFLAGSG" cat > conftest.$ac_ext < @@ -1991,7 +2127,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:1995: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2131: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 @@ -2015,7 +2151,7 @@ rm -f conftest* echo $ac_n "checking whether lrand48 needs to be declared with -ansi""... $ac_c" 1>&6 -echo "configure:2019: checking whether lrand48 needs to be declared with -ansi" >&5 +echo "configure:2155: checking whether lrand48 needs to be declared with -ansi" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' @@ -2025,7 +2161,7 @@ cross_compiling=$ac_cv_prog_cxx_cross CXXFLAGS="$CXXFLAGSG" cat > conftest.$ac_ext < @@ -2041,7 +2177,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2045: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2181: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""no" 1>&6 @@ -2062,7 +2198,7 @@ rm -f conftest* echo $ac_n "checking whether getrusage is properly declared""... $ac_c" 1>&6 -echo "configure:2066: checking whether getrusage is properly declared" >&5 +echo "configure:2202: checking whether getrusage is properly declared" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' @@ -2071,7 +2207,7 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext < @@ -2083,7 +2219,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2087: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2223: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t"""yes"" 1>&6 @@ -2101,7 +2237,7 @@ fi rm -f conftest* echo $ac_n "checking whether isnan is declared with debug flags""... $ac_c" 1>&6 -echo "configure:2105: checking whether isnan is declared with debug flags" >&5 +echo "configure:2241: checking whether isnan is declared with debug flags" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' @@ -2112,7 +2248,7 @@ cross_compiling=$ac_cv_prog_cxx_cross CXXFLAGS=$CXXFLAGSG deal_II_isnan_flag="" cat > conftest.$ac_ext < @@ -2124,7 +2260,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2128: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2264: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t"""yes"" 1>&6 @@ -2140,7 +2276,7 @@ rm -f conftest* if test "x$deal_II_isnan_flag" = "x" ; then cat > conftest.$ac_ext < @@ -2152,7 +2288,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2156: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2292: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t"""yes"" 1>&6 @@ -2172,7 +2308,7 @@ rm -f conftest* for testflag in -D_ISOC99_SOURCE -D__EXTENSIONS__ ; do CXXFLAGS="$CXXFLAGSG $testflag" cat > conftest.$ac_ext < @@ -2184,7 +2320,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2188: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2324: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* deal_II_isnan_flag="-DHAVE_ISNAN $testflag" @@ -2197,7 +2333,7 @@ fi rm -f conftest* cat > conftest.$ac_ext < @@ -2209,7 +2345,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2213: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2349: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* deal_II_isnan_flag="-DHAVE_UNDERSCORE_ISNAN $testflag" @@ -2231,7 +2367,7 @@ rm -f conftest* fi echo $ac_n "checking whether isnan is declared with optimized flags""... $ac_c" 1>&6 -echo "configure:2235: checking whether isnan is declared with optimized flags" >&5 +echo "configure:2371: checking whether isnan is declared with optimized flags" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' @@ -2242,7 +2378,7 @@ cross_compiling=$ac_cv_prog_cxx_cross CXXFLAGS=$CXXFLAGSO deal_II_isnan_flag="" cat > conftest.$ac_ext < @@ -2254,7 +2390,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2258: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2394: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t"""yes"" 1>&6 @@ -2270,7 +2406,7 @@ rm -f conftest* if test "x$deal_II_isnan_flag" = "x" ; then cat > conftest.$ac_ext < @@ -2282,7 +2418,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2286: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2422: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t"""yes"" 1>&6 @@ -2302,7 +2438,7 @@ rm -f conftest* for testflag in -D_ISOC99_SOURCE -D__EXTENSIONS__ ; do CXXFLAGS="$CXXFLAGSO $testflag" cat > conftest.$ac_ext < @@ -2314,7 +2450,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2318: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2454: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* deal_II_isnan_flag="-DHAVE_ISNAN $testflag" @@ -2327,7 +2463,7 @@ fi rm -f conftest* cat > conftest.$ac_ext < @@ -2339,7 +2475,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2343: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2479: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* deal_II_isnan_flag="-DHAVE_UNDERSCORE_ISNAN $testflag" @@ -2370,9 +2506,9 @@ cross_compiling=$ac_cv_prog_cxx_cross CXXFLAGS=$CXXFLAGSG echo $ac_n "checking for rand_r""... $ac_c" 1>&6 -echo "configure:2374: checking for rand_r" >&5 +echo "configure:2510: checking for rand_r" >&5 cat > conftest.$ac_ext < @@ -2384,7 +2520,7 @@ int i=rand_r(&i); ; return 0; } EOF -if { (eval echo configure:2388: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2524: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""found" 1>&6 @@ -2407,12 +2543,12 @@ rm -f conftest* for ac_func in gethostname do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2411: checking for $ac_func" >&5 +echo "configure:2547: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2578: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2467,7 +2603,7 @@ done # Extract the first word of "f77", so it can be a program name with args. set dummy f77; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2471: checking for $ac_word" >&5 +echo "configure:2607: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_F77'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2503,7 +2639,7 @@ if test "x$F77" = "x" ; then # Extract the first word of "g77", so it can be a program name with args. set dummy g77; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2507: checking for $ac_word" >&5 +echo "configure:2643: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_F77'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2654,7 +2790,7 @@ fi # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2658: checking for $ac_word" >&5 +echo "configure:2794: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2692,7 +2828,7 @@ fi echo $ac_n "checking for HSL subroutines""... $ac_c" 1>&6 -echo "configure:2696: checking for HSL subroutines" >&5 +echo "configure:2832: checking for HSL subroutines" >&5 hsl_subroutines="" if test -r contrib/hsl/source/ma27.f ; then hsl_subroutines="$hsl_subroutines MA27" @@ -2757,7 +2893,7 @@ else fi echo $ac_n "checking for kdoc""... $ac_c" 1>&6 -echo "configure:2761: checking for kdoc" >&5 +echo "configure:2897: checking for kdoc" >&5 if test "$kdocdir" != ${DEAL2_DIR}/contrib/kdoc/bin ; then if test -r $kdocdir/kdoc ; then echo "$ac_t""found" 1>&6 @@ -2793,7 +2929,7 @@ if test "$docxx" = to-be-determined ; then # Extract the first word of ""doc++"", so it can be a program name with args. set dummy "doc++"; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2797: checking for $ac_word" >&5 +echo "configure:2933: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_docxx'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2827,7 +2963,7 @@ fi else echo $ac_n "checking for doc++""... $ac_c" 1>&6 -echo "configure:2831: checking for doc++" >&5 +echo "configure:2967: checking for doc++" >&5 if test -x "$docxx" ; then echo "$ac_t""yes" 1>&6 else @@ -2850,16 +2986,16 @@ cross_compiling=$ac_cv_prog_cxx_cross CXXFLAGS="$CXXFLAGSG" echo $ac_n "checking for consistency of CXXFLAGSG flags""... $ac_c" 1>&6 -echo "configure:2854: checking for consistency of CXXFLAGSG flags" >&5 +echo "configure:2990: checking for consistency of CXXFLAGSG flags" >&5 cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2999: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 @@ -2877,16 +3013,16 @@ rm -f conftest* CXXFLAGS="$CXXFLAGSO" echo $ac_n "checking for consistency of CXXFLAGSO flags""... $ac_c" 1>&6 -echo "configure:2881: checking for consistency of CXXFLAGSO flags" >&5 +echo "configure:3017: checking for consistency of CXXFLAGSO flags" >&5 cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3026: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 -- 2.39.5