[glib/clang-cl-support: 1/2] gmacros.h: Support building and usage with clang-cl



commit 8f470498ed3f437c12928b59e42bf6a0ae1c7207
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Jul 10 00:19:40 2019 +0800

    gmacros.h: Support building and usage with clang-cl
    
    For the deprecation warning macros, use GCC-style definitions so that we
    will not break the build on clang-cl.
    
    Also check for the __clang__ macro that will be pre-defined for clang-cl
    builds so that we can ensure that we enable g_autoptr support, which
    works for GCC and CLang.

 glib/gmacros.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/glib/gmacros.h b/glib/gmacros.h
index 2764d9552..bf735883d 100644
--- a/glib/gmacros.h
+++ b/glib/gmacros.h
@@ -938,7 +938,7 @@
 #define G_UNLIKELY(expr) (expr)
 #endif
 
-#if    __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+#if    __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || defined (__clang__)
 #define G_DEPRECATED __attribute__((__deprecated__))
 #elif defined(_MSC_VER) && (_MSC_VER >= 1300)
 #define G_DEPRECATED __declspec(deprecated)
@@ -946,7 +946,7 @@
 #define G_DEPRECATED
 #endif
 
-#if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+#if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined (__clang__)
 #define G_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead")))
 #elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320)
 #define G_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead"))
@@ -954,7 +954,7 @@
 #define G_DEPRECATED_FOR(f) G_DEPRECATED
 #endif
 
-#if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+#if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined (__clang__)
 #define G_UNAVAILABLE(maj,min) __attribute__((deprecated("Not available before " #maj "." #min)))
 #elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320)
 #define G_UNAVAILABLE(maj,min) __declspec(deprecated("is not available before " #maj "." #min))
@@ -1021,7 +1021,7 @@
 
 #ifndef __GI_SCANNER__
 
-#ifdef __GNUC__
+#if defined (__GNUC__) || defined (__clang__)
 
 /* these macros are private */
 #define _GLIB_AUTOPTR_FUNC_NAME(TypeName) glib_autoptr_cleanup_##TypeName


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]