]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Detect __PRETTY_FUNCTION__, and if not available work around.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 6 May 2002 07:39:02 +0000 (07:39 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 6 May 2002 07:39:02 +0000 (07:39 +0000)
git-svn-id: https://svn.dealii.org/trunk@5809 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/aclocal.m4
deal.II/base/include/base/exceptions.h
deal.II/configure.in

index 01679112e8d290dd2ff27debe6b440b3611c9174..6cee93809fa20d2f6e2387ff0a9f4bf7ae339915 100644 (file)
@@ -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 <iostream>
+    ],
+    [
+       std::cout << __PRETTY_FUNCTION__ << std::endl;
+    ],
+    [
+      AC_MSG_RESULT(available)
+    ],
+    [
+      AC_MSG_RESULT(not available)
+      AC_MSG_CHECKING(for __func__)
+      AC_TRY_COMPILE(
+        [
+#      include <iostream>
+        ],
+        [
+         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.])
     ])
 ])
 
index 346bc7b10aeed42a814f52b50fd8383585662a36..a41879ef074ef12fa6120885ea320d08ca54206f 100644 (file)
 #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
  *  @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
index 02ccdf5ed6416e1e61fb39c09410385f6c3571d2..30ffe964685730d8e5bf134c0398af92cf269734 100644 (file)
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.