Browse Source

libdpkg: Define a __func__ fallback for old C++ modes

If we are not using C++11, then define __func__ as __PRETTY_FUNCTION__
if using GCC, or to the more widely available __FUNCTION__ otherwise.

We do not bother with fallbacks for C because configure already makes
sure the compiler has a working __func__ identifier.
Guillem Jover 14 years ago
parent
commit
3ce18b7b55
1 changed files with 10 additions and 1 deletions
  1. 10 1
      lib/dpkg/macros.h

+ 10 - 1
lib/dpkg/macros.h

@@ -2,7 +2,7 @@
  * libdpkg - Debian packaging suite library routines
  * macros.h - C language support macros
  *
- * Copyright © 2008, 2009 Guillem Jover <guillem@debian.org>
+ * Copyright © 2008-2012 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -71,6 +71,15 @@
 #define DPKG_ATTR_SENTINEL
 #endif
 
+/* For C++, define a __func__ fallback in case it's not natively supported. */
+#if defined(__cplusplus) && __cplusplus < 201103L
+# if DPKG_GCC_VERSION >= 0x0200
+#  define __func__ __PRETTY_FUNCTION__
+# else
+#  define __func__ __FUNCTION__
+# endif
+#endif
+
 #ifdef __cplusplus
 #define DPKG_BEGIN_DECLS	extern "C" {
 #define DPKG_END_DECLS		}