A while ago, I wrote about our new better way to do deprecation warnings in the GTK+ stack by letting the compiler do the warnings. That work came out of the Montreal summit. Here we are, half a year later, and the our next get-together (the GTK+ hackfest last week in Brno) produces another big improvement for our deprecation technology.
This time it was Emmanuele Bassi who took the initiative and added versioning information to our deprecation annotations. This means that it is now possible to say to your compiler:
Warn me about deprecations up to version 2.30, but I don’t want to chase the recent deprecations that have been going into 2.31 yet.
Doing this is just as easy as turning off deprecation warnings altogether. You just define a preprocessor symbol. In the case of GLib, it would be
#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_30
While Emmanuele was at it, he threw in another nicety: You can now get compiler warnings for ‘too new’ API too. And it is just as easy:
#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_28
will produce a compiler warning if you use API that was not available in GLib 2.28. This comes in handy when you want to ensure that your application continues to build on older distributions.
GTK+ has these new deprecations as well, the relevant preprocessor symbols to use here are GDK_VERSION_MIN_REQUIRED and GDK_VERSION_MAX_ALLOWED.
Versioned deprecations should make it a lot easier to gradually port applications to new API, as opposed to the current situation where you either have to chase all the latest API or ignore deprecations altogether. Thanks, Emmanuele !