[glib: 1/3] gmacros.h: Complete the use of GLIB_AVAILABLE_MACRO_IN_*
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/3] gmacros.h: Complete the use of GLIB_AVAILABLE_MACRO_IN_*
- Date: Thu, 8 Apr 2021 15:52:28 +0000 (UTC)
commit f20bcf2969c02a24d25ca8cd37f64dcd03c5426f
Author: Gaël Bonithon <gael xfce org>
Date: Thu Apr 8 01:51:59 2021 +0200
gmacros.h: Complete the use of GLIB_AVAILABLE_MACRO_IN_*
This adds `GLIB_AVAILABLE_MACRO_IN_*` where needed, or a comment when
such use is not possible.
Fixes #2376.
glib/gmacros.h | 35 +++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
---
diff --git a/glib/gmacros.h b/glib/gmacros.h
index 27c8a1c89..2a6e721c9 100644
--- a/glib/gmacros.h
+++ b/glib/gmacros.h
@@ -188,6 +188,11 @@
*
* Since: 2.58
*/
+/* Note: We can’t annotate this with GLIB_AVAILABLE_MACRO_IN_2_58 because it’s
+ * used within the GLib headers in function declarations which are always
+ * evaluated when a header is included. This results in warnings in third party
+ * code which includes glib.h, even if the third party code doesn’t use the new
+ * macro itself. */
#if G_GNUC_CHECK_VERSION(2, 96)
#define G_GNUC_PURE __attribute__((__pure__))
@@ -517,14 +522,16 @@
#define G_GNUC_SCANF( format_idx, arg_idx ) \
__attribute__((__format__ (gnu_scanf, format_idx, arg_idx)))
#define G_GNUC_STRFTIME( format_idx ) \
- __attribute__((__format__ (gnu_strftime, format_idx, 0)))
+ __attribute__((__format__ (gnu_strftime, format_idx, 0))) \
+ GLIB_AVAILABLE_MACRO_IN_2_60
#else
#define G_GNUC_PRINTF( format_idx, arg_idx ) \
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
#define G_GNUC_SCANF( format_idx, arg_idx ) \
__attribute__((__format__ (__scanf__, format_idx, arg_idx)))
#define G_GNUC_STRFTIME( format_idx ) \
- __attribute__((__format__ (__strftime__, format_idx, 0)))
+ __attribute__((__format__ (__strftime__, format_idx, 0))) \
+ GLIB_AVAILABLE_MACRO_IN_2_60
#endif
#define G_GNUC_FORMAT( arg_idx ) \
__attribute__((__format_arg__ (arg_idx)))
@@ -539,7 +546,8 @@
#else /* !__GNUC__ */
#define G_GNUC_PRINTF( format_idx, arg_idx )
#define G_GNUC_SCANF( format_idx, arg_idx )
-#define G_GNUC_STRFTIME( format_idx )
+#define G_GNUC_STRFTIME( format_idx ) \
+ GLIB_AVAILABLE_MACRO_IN_2_60
#define G_GNUC_FORMAT( arg_idx )
/* NOTE: MSVC has __declspec(noreturn) but unlike GCC __attribute__,
* __declspec can only be placed at the start of the function prototype
@@ -580,11 +588,14 @@
* Since: 2.60
*/
#if G_GNUC_CHECK_VERSION(6, 0)
-#define G_GNUC_FALLTHROUGH __attribute__((fallthrough))
+#define G_GNUC_FALLTHROUGH __attribute__((fallthrough)) \
+ GLIB_AVAILABLE_MACRO_IN_2_60
#elif g_macro__has_attribute (fallthrough)
-#define G_GNUC_FALLTHROUGH __attribute__((fallthrough))
+#define G_GNUC_FALLTHROUGH __attribute__((fallthrough)) \
+ GLIB_AVAILABLE_MACRO_IN_2_60
#else
-#define G_GNUC_FALLTHROUGH
+#define G_GNUC_FALLTHROUGH \
+ GLIB_AVAILABLE_MACRO_IN_2_60
#endif /* __GNUC__ */
/**
@@ -636,9 +647,11 @@
*/
#if G_GNUC_CHECK_VERSION(4, 5) || defined(__clang__)
#define G_GNUC_DEPRECATED_FOR(f) \
- __attribute__((deprecated("Use " #f " instead")))
+ __attribute__((deprecated("Use " #f " instead"))) \
+ GLIB_AVAILABLE_MACRO_IN_2_26
#else
-#define G_GNUC_DEPRECATED_FOR(f) G_GNUC_DEPRECATED
+#define G_GNUC_DEPRECATED_FOR(f) G_GNUC_DEPRECATED \
+ GLIB_AVAILABLE_MACRO_IN_2_26
#endif /* __GNUC__ */
#ifdef __ICC
@@ -912,9 +925,11 @@
* Since: 2.60
*/
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
-#define G_ALIGNOF(type) _Alignof (type)
+#define G_ALIGNOF(type) _Alignof (type) \
+ GLIB_AVAILABLE_MACRO_IN_2_60
#else
-#define G_ALIGNOF(type) (G_STRUCT_OFFSET (struct { char a; type b; }, b))
+#define G_ALIGNOF(type) (G_STRUCT_OFFSET (struct { char a; type b; }, b)) \
+ GLIB_AVAILABLE_MACRO_IN_2_60
#endif
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]