From: Wolfgang Bangerth Date: Mon, 6 May 2002 07:39:02 +0000 (+0000) Subject: Detect __PRETTY_FUNCTION__, and if not available work around. X-Git-Tag: v8.0.0~18052 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31fd4dd9ebd4715dcfe167590976d5af6ac7699f;p=dealii.git Detect __PRETTY_FUNCTION__, and if not available work around. git-svn-id: https://svn.dealii.org/trunk@5809 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/aclocal.m4 b/deal.II/aclocal.m4 index 01679112e8..6cee93809f 100644 --- a/deal.II/aclocal.m4 +++ b/deal.II/aclocal.m4 @@ -1305,6 +1305,65 @@ using namespace StandardExceptions; +dnl ------------------------------------------------------------- +dnl Gcc and some other compilers have __PRETTY_FUNCTION__, showing +dnl an unmangled version of the function we are presently in, +dnl while __FUNCTION__ (or __func__ in ISO C99) simply give the +dnl function name which would not include the arguments of that +dnl function, leading to problems in C++ with overloaded function +dnl names. +dnl +dnl If __PRETTY_FUNCTION__ is not available, try to find out whether +dnl __func__ is available and use the preprocessor to set the first +dnl thing to the second. If this is also not the case, then set it +dnl to something indicating non-availability. +dnl +dnl Usage: DEAL_II_HAVE_PRETTY_FUNCTION +dnl +dnl ------------------------------------------------------------- +AC_DEFUN(DEAL_II_HAVE_PRETTY_FUNCTION, dnl +[ + AC_MSG_CHECKING(for __PRETTY_FUNCTION__) + AC_LANG(C++) + CXXFLAGS="$CXXFLAGSG" + AC_TRY_COMPILE( + [ +# include + ], + [ + std::cout << __PRETTY_FUNCTION__ << std::endl; + ], + [ + AC_MSG_RESULT(available) + ], + [ + AC_MSG_RESULT(not available) + AC_MSG_CHECKING(for __func__) + AC_TRY_COMPILE( + [ +# include + ], + [ + std::cout << __func__ << std::endl; + ], + [ + AC_MSG_RESULT(available) + x=__func__ + ], + [ + AC_MSG_RESULT(not available) + x="(not available)" + ]) + AC_DEFINE_UNQUOTED(__PRETTY_FUNCTION__, $x, + [If already available, do not define at all. Otherwise, define + to __func__ if that is available. In all other cases, + indicate that no information about the present function + is available for this compiler.]) + ]) +]) + + + dnl ------------------------------------------------------------- dnl IBM xlC 5.0 from the VisualAge C++ pack has a bug with the following dnl code. We can work around it if we insert code like "using namespace std;" @@ -1342,8 +1401,8 @@ AC_DEFUN(DEAL_II_CHECK_IBM_XLC_ERROR, dnl AC_MSG_RESULT(yes. using workaround) AC_DEFINE(XLC_WORK_AROUND_STD_BUG, 1, [Define if we have to work around a bug in IBM's xlC compiler. -See the aclocal.m4 file in the top-level directory for a description -of this bug.]) + See the aclocal.m4 file in the top-level directory for a + description of this bug.]) ]) ]) diff --git a/deal.II/base/include/base/exceptions.h b/deal.II/base/include/base/exceptions.h index 346bc7b10a..a41879ef07 100644 --- a/deal.II/base/include/base/exceptions.h +++ b/deal.II/base/include/base/exceptions.h @@ -27,11 +27,6 @@ #endif -#ifndef __GNUC__ -# define __PRETTY_FUNCTION__ "(unknown)" -#endif - - /** * This class should be used as a base class for * all exception classes. Do not use its methods @@ -140,9 +135,10 @@ * @p{ExcDomain}) and transferred to the @p{__IssueError_Assert} * function. * - * @p{__PRETTY__FUNCTION__} is a macro defined only by the GNU CC - * compiler and gives the name of the function. If another compiler - * is used, we set @p{__PRETTY_FUNCTION__ = "(unknown)"}. + * @p{__PRETTY__FUNCTION__} is a macro defined by some compilers and + * gives the name of the function. If another compiler is used, we + * try to set this function to something reasonable, if the compiler + * provides us with that, and @p{"(not available)"} otherwise. * * In @p{__IssueError} the given data * is transferred into the @p{exc} object by calling the diff --git a/deal.II/configure.in b/deal.II/configure.in index 02ccdf5ed6..30ffe96468 100644 --- a/deal.II/configure.in +++ b/deal.II/configure.in @@ -159,6 +159,7 @@ DEAL_II_CHECK_TEMPL_CONST_MEM_PTR_BUG DEAL_II_CHECK_CONST_MEM_FUN_PTR_BUG DEAL_II_CHECK_IMPLEMENTED_PURE_FUNCTION_BUG DEAL_II_CHECK_TEMPLATE_TEMPLATE_TYPEDEF_BUG +DEAL_II_HAVE_PRETTY_FUNCTION DEAL_II_HAVE_STD_ITERATOR DEAL_II_HAVE_STD_STRINGSTREAM DEAL_II_HAVE_STD_NUMERIC_LIMITS