Fix false deprecation warnings on old GCC/MSVC

Closes #2472
This commit is contained in:
Evan Miller 2021-09-06 15:48:08 -04:00 committed by Philip Withnall
parent eafcdd2eb6
commit 508352339a
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"))