Add macro FUNC that expands to __PRETTY_FUNCTION__ or __func__
authorSøren Sandmann <sandmann@redhat.com>
Sat, 19 May 2007 19:53:37 +0000 (15:53 -0400)
committerSøren Sandmann <sandmann@redhat.com>
Sat, 19 May 2007 19:53:37 +0000 (15:53 -0400)
depending on the compiler.

configure.ac
pixman/pixman-private.h

index a4aeb1c..18a0ce4 100644 (file)
@@ -1,4 +1,3 @@
-
 dnl  Copyright 2005 Red Hat, Inc.
 dnl 
 dnl  Permission to use, copy, modify, distribute, and sell this software and its
index 272fbed..bb0d4b1 100644 (file)
 
 #define DEBUG 1
 
+#if defined (__GNUC__)
+#  define FUNC     ((const char*) (__PRETTY_FUNCTION__))
+#elif defined (__sun) || (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
+#  define FUNC     ((const char*) (__func__))
+#else
+#  define FUNC     ((const char*) ("???"))
+#endif
+
 #if DEBUG
 
 #define return_if_fail(expr)                                                   \
@@ -17,7 +25,7 @@
        {                                                                       \
            if (!(expr))                                                        \
            {                                                                   \
-               fprintf(stderr, "In %s: %s failed\n", __FUNCTION__, #expr);     \
+               fprintf(stderr, "In %s: %s failed\n", FUNC, #expr);     \
                return;                                                         \
            }                                                                   \
        }                                                                       \
@@ -28,7 +36,7 @@
        {                                                                       \
            if (!(expr))                                                        \
            {                                                                   \
-               fprintf(stderr, "In %s: %s failed\n", __FUNCTION__, #expr);     \
+               fprintf(stderr, "In %s: %s failed\n", FUNC, #expr);     \
                return (retval);                                                \
            }                                                                   \
        }                                                                       \