Просмотр исходного кода

libdpkg: Move __func__ and nullptr definitions to libcompat

These are really compatibility macros for systems w/o the required
compiler support.

We need to duplicate the logic for LIBCOMPAT_GCC_VERSION, but for now
we will keep that and DPKG_GCC_VERSION to avoid having to make compat.h
a public header.
Guillem Jover лет назад: 12
Родитель
Сommit
338374a655
2 измененных файлов с 21 добавлено и 13 удалено
  1. 21 0
      lib/compat/compat.h
  2. 0 13
      lib/dpkg/macros.h

+ 21 - 0
lib/compat/compat.h

@@ -39,6 +39,27 @@
 #include <string.h>
 #endif
 
+/* Language definitions. */
+
+#ifdef __GNUC__
+#define LIBCOMPAT_GCC_VERSION (__GNUC__ << 8 | __GNUC_MINOR__)
+#else
+#define LIBCOMPAT_GCC_VERSION 0
+#endif
+
+/* For C++, define a __func__ fallback in case it's not natively supported. */
+#if defined(__cplusplus) && __cplusplus < 201103L
+# if LIBCOMPAT_GCC_VERSION >= 0x0200
+#  define __func__ __PRETTY_FUNCTION__
+# else
+#  define __func__ __FUNCTION__
+# endif
+#endif
+
+#if defined(__cplusplus) && __cplusplus < 201103L
+#define nullptr 0
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif

+ 0 - 13
lib/dpkg/macros.h

@@ -71,19 +71,6 @@
 #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
-
-#if defined(__cplusplus) && __cplusplus < 201103L
-#define nullptr 0
-#endif
-
 #ifdef __cplusplus
 #define DPKG_BEGIN_DECLS	extern "C" {
 #define DPKG_END_DECLS		}