From 2bc73d7281383c42fa32009eed639a4f4cc274c5 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 9 Jul 2019 18:17:02 +0800 Subject: [PATCH 1/2] glib/gmacros.h: Check for __clang__ for g_autoptr clang-cl does support __attribute__((cleanup)), which is what is used for the g_auto* macros, but neither it, nor clang.exe defines __GNUC__ when they are used in a MSVC cmd.exe environment. It does, however, define __clang__. So, check for the presence of the __clang__ macro to enable g_autoptr as well, so that we can build things with MSVC builds that make use of g_autoptr via pretending to be MSVC by using clang-cl. --- glib/gmacros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/gmacros.h b/glib/gmacros.h index 2764d9552..5ca7beb38 100644 --- a/glib/gmacros.h +++ b/glib/gmacros.h @@ -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 From d616ca25ffebdf5dc39746537546d1b67e661d34 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 10 Jul 2019 10:47:35 +0800 Subject: [PATCH 2/2] gmacros.h: Support deprecation macros better on clang-cl Use the GCC-style definition for the deprecation warning macros so that builds using those won't break due to how they are placed as clang-cl seems to not support __declspec(deprecated) very well. Also make sure that we do indeed support the temparary disabling of deprecation warnings on clang-cl, as the MSVC ones don't really work on clang-cl. --- glib/gmacros.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/glib/gmacros.h b/glib/gmacros.h index 5ca7beb38..79077e23b 100644 --- a/glib/gmacros.h +++ b/glib/gmacros.h @@ -581,7 +581,7 @@ * * Since: 2.2 */ -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || defined (__clang__) #define G_GNUC_DEPRECATED __attribute__((__deprecated__)) #else #define G_GNUC_DEPRECATED @@ -610,7 +610,7 @@ * * Since: 2.26 */ -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined (__clang__) #define G_GNUC_DEPRECATED_FOR(f) \ __attribute__((deprecated("Use " #f " instead"))) #else @@ -629,7 +629,7 @@ _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"") #define G_GNUC_END_IGNORE_DEPRECATIONS \ _Pragma ("GCC diagnostic pop") -#elif defined (_MSC_VER) && (_MSC_VER >= 1500) +#elif defined (_MSC_VER) && (_MSC_VER >= 1500) && !defined (__clang__) #define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ __pragma (warning (push)) \ __pragma (warning (disable : 4996)) @@ -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))