[cig-commits] r14405 - cs/autoconf/trunk

brad at geodynamics.org brad at geodynamics.org
Fri Mar 20 11:44:02 PDT 2009


Author: brad
Date: 2009-03-20 11:44:01 -0700 (Fri, 20 Mar 2009)
New Revision: 14405

Added:
   cs/autoconf/trunk/cit_funcstring.m4
Log:
Added macro for checking whether compiler sets variable with function name (for use in error messages).

Added: cs/autoconf/trunk/cit_funcstring.m4
===================================================================
--- cs/autoconf/trunk/cit_funcstring.m4	                        (rev 0)
+++ cs/autoconf/trunk/cit_funcstring.m4	2009-03-20 18:44:01 UTC (rev 14405)
@@ -0,0 +1,47 @@
+# -*- Autoconf -*-
+
+## Autoconf macro for testing if compiler provides string with
+## function names.
+##
+
+# CIT_HAVE_FUNTIONSTRING
+#   Defines preprocessor macro __FUNCTION_NAME__.
+# ------------
+AC_DEFUN([CIT_FUNCTIONSTRING], [
+  AC_LANG(C++)
+  set_function_name=no
+
+  AC_MSG_CHECKING([whether C++ compiler defines __PRETTY_FUNCTION__])
+  AC_COMPILE_IFELSE(
+    [AC_LANG_PROGRAM([[]],
+ 	             [[const char* name = __PRETTY_FUNCTION__;]])],
+    [AC_MSG_RESULT(yes)
+     set_function_name=yes
+     AC_DEFINE([__FUNCTION_NAME__], [__PRETTY_FUNCTION__], [Define __FUNCTION_NAME__ to __PRETTY_FUNCTION__.])],
+    [AC_MSG_RESULT(no)])
+
+  if test "$set_function_name" == no; then
+    AC_MSG_CHECKING([whether C++ compiler defines __FUNCTION__])
+    AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM([[]],
+ 	               [[const char* name = __FUNCTION__;]])],
+      [AC_MSG_RESULT(yes)
+       set_function_name=yes
+       AC_DEFINE([__FUNCTION_NAME__], [__FUNCTION__], [Define __FUNCTION_NAME__ to __FUNCTION__.])],
+      [AC_MSG_RESULT(no)])
+    fi
+
+  if test "$set_function_name" == no; then
+    AC_MSG_CHECKING([whether C++ compiler defines __func__])
+    AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM([[]],
+ 	               [[const char* name = __func__;]])],
+      [AC_MSG_RESULT(yes)
+       set_function_name=yes
+       AC_DEFINE([__FUNCTION_NAME__], [__func__], [Define __FUNCTION_NAME__ to __func__.])],
+      [AC_MSG_RESULT(no)])
+    fi
+]))
+
+
+dnl end of file



More information about the CIG-COMMITS mailing list