summaryrefslogtreecommitdiff
path: root/clutter/clutter-macros.h
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2015-07-11 10:03:57 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2015-07-11 10:18:18 +0100
commit8a24ad83c91551e1c6eaa05a0f1dac022cf4887a (patch)
tree4cb916d873b655ab3d6f5aae73d485f67ee8dca3 /clutter/clutter-macros.h
parentb151898534b08eb8bc0136883d2204c6b612bc36 (diff)
downloadclutter-8a24ad83c91551e1c6eaa05a0f1dac022cf4887a.tar.gz
Add macros for deprecating macros
We want to be able to deprecate macros, but right now the best we can do is to wrap them with things like: #ifndef CLUTTER_DISABLE_DEPRECATED # define A_MACRO_I_WANT_TO_DEPRECATE ... #endif Which requires adding a new symbol to the build, and will cause a build error instead of a compiler/pre-processor warning. Fortunately, we can use the _Pragma() keyword introduced by C99 and supported by GCC to add a warning to the output, while leaving the macro itself intact. GCC does not have a "deprecated" pragma, so we have to use a generic warning; this also means we cannot do nifty things like concatenating strings and the like, as we do for the "deprecated" attribute. The macro deprecation symbol should have the same affordances as the function deprecation one, and evaluate to nothing if the required version is lower than the current version; or if the global toggle for deprecation warnings is in effect.
Diffstat (limited to 'clutter/clutter-macros.h')
-rw-r--r--clutter/clutter-macros.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/clutter/clutter-macros.h b/clutter/clutter-macros.h
index e38ec23a1..349269936 100644
--- a/clutter/clutter-macros.h
+++ b/clutter/clutter-macros.h
@@ -96,6 +96,12 @@
#define _CLUTTER_EXTERN extern
#endif
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#define _CLUTTER_GNUC_DO_PRAGMA(x) _Pragma(G_STRINGIFY (x))
+#define _CLUTTER_DEPRECATED_MACRO _CLUTTER_GNUC_DO_PRAGMA(GCC warning "Deprecated macro")
+#define _CLUTTER_DEPRECATED_MACRO_FOR(f) _CLUTTER_GNUC_DO_PRAGMA(GCC warning #f)
+#endif
+
/* these macros are used to mark deprecated functions, and thus have to be
* exposed in a public header.
*
@@ -106,10 +112,14 @@
#define CLUTTER_DEPRECATED _CLUTTER_EXTERN
#define CLUTTER_DEPRECATED_FOR(f) _CLUTTER_EXTERN
#define CLUTTER_UNAVAILABLE(maj,min) _CLUTTER_EXTERN
+#define CLUTTER_DEPRECATED_MACRO
+#define CLUTTER_DEPRECATED_MACRO_FOR(f)
#else
#define CLUTTER_DEPRECATED G_DEPRECATED _CLUTTER_EXTERN
#define CLUTTER_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _CLUTTER_EXTERN
#define CLUTTER_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min) _CLUTTER_EXTERN
+#define CLUTTER_DEPRECATED_MACRO _CLUTTER_DEPRECATED_MACRO
+#define CLUTTER_DEPRECATED_MACRO_FOR(f) _CLUTTER_DEPRECATED_MACRO_FOR(f)
#endif
#define CLUTTER_AVAILABLE_IN_ALL _CLUTTER_EXTERN
@@ -341,9 +351,13 @@
#if CLUTTER_VERSION_MIN_REQUIRED >= CLUTTER_VERSION_1_24
# define CLUTTER_DEPRECATED_IN_1_24 CLUTTER_DEPRECATED
# define CLUTTER_DEPRECATED_IN_1_24_FOR(f) CLUTTER_DEPRECATED_FOR(f)
+# define CLUTTER_MACRO_DEPRECATED_IN_1_24 CLUTTER_DEPRECATED_MACRO
+# define CLUTTER_MACRO_DEPRECATED_IN_1_24_FOR(f) CLUTTER_DEPRECATED_MACRO_FOR(f)
#else
# define CLUTTER_DEPRECATED_IN_1_24 _CLUTTER_EXTERN
# define CLUTTER_DEPRECATED_IN_1_24_FOR(f) _CLUTTER_EXTERN
+# define CLUTTER_MACRO_DEPRECATED_IN_1_24
+# define CLUTTER_MACRO_DEPRECATED_IN_1_24_FOR(f)
#endif
#if CLUTTER_VERSION_MAX_ALLOWED < CLUTTER_VERSION_1_24