Merge branch 'gcc-suppress-deprecated-2' into 'main'

Fix false deprecation warnings on old GCC/MSVC

Closes #2472

See merge request GNOME/glib!2234
This commit is contained in:
Philip Withnall 2021-09-07 10:45:06 +00:00
commit c9b1e6654e
2 changed files with 13 additions and 2 deletions

View File

@ -738,6 +738,7 @@ G_HAVE_GNUC_VARARGS
G_HAVE_ISO_VARARGS
G_HAVE_GROWING_STACK
G_VA_COPY_AS_ARRAY
GLIB_CANNOT_IGNORE_DEPRECATIONS
GLIB_DEPRECATED
GLIB_DEPRECATED_FOR
GLIB_UNAVAILABLE

View File

@ -720,6 +720,7 @@
#else
#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS
#define G_GNUC_END_IGNORE_DEPRECATIONS
#define GLIB_CANNOT_IGNORE_DEPRECATIONS
#endif
/**
@ -1090,7 +1091,14 @@
#define G_UNLIKELY(expr) (expr)
#endif
#if G_GNUC_CHECK_VERSION(3, 1) || defined(__clang__)
/* GLIB_CANNOT_IGNORE_DEPRECATIONS is defined above for compilers that do not
* have a way to temporarily suppress deprecation warnings. In these cases,
* suppress the deprecated attribute altogether (otherwise a simple #include
* <glib.h> will emit a barrage of warnings).
*/
#if defined(GLIB_CANNOT_IGNORE_DEPRECATIONS)
#define G_DEPRECATED
#elif G_GNUC_CHECK_VERSION(3, 1) || defined(__clang__)
#define G_DEPRECATED __attribute__((__deprecated__))
#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
#define G_DEPRECATED __declspec(deprecated)
@ -1098,7 +1106,9 @@
#define G_DEPRECATED
#endif
#if G_GNUC_CHECK_VERSION(4, 5) || defined(__clang__)
#if defined(GLIB_CANNOT_IGNORE_DEPRECATIONS)
#define G_DEPRECATED_FOR(f) G_DEPRECATED
#elif G_GNUC_CHECK_VERSION(4, 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"))