Add flexible API version boundaries
authorEmmanuele Bassi <ebassi@gnome.org>
Mon, 20 Feb 2012 16:20:15 +0000 (16:20 +0000)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 27 Feb 2012 04:58:41 +0000 (23:58 -0500)
commit34aeeb7d64a0433f7994dd2b3f60bc018f0a84c1
treec01b548de1751785bfe50d8ee035b013b5e60490
parentd70634526d43a9d9281301c2097c788ca575e318
Add flexible API version boundaries

There are cases when it should be possible to define at compile time
what range of functions and types should be used, in order to get,
or restrict, the compiler warnings for deprecated or newly added
types or functions.

For instance, if GLib introduces a deprecation warning on a type in
version 2.32, application code can decide to specify the minimum and
maximum boundary of the used API to be 2.30; when compiling against
a new version of GLib, this would produce the following results:

  - all deprecations introduced prior to 2.32 would emit compiler
    warnings when used by the application code;
  - all deprecations introduced in 2.32 would not emit compiler
    warnings when used by the application code;
  - all new symbols introduced in 2.32 would emit a compiler warning.

Using this scheme it should be possible to have fairly complex
situations, like the following one:

  assuming that an application is compiled with:
    GLIB_VERSION_MIN_REQUIRED = GLIB_VERSION_2_30
    GLIB_VERSION_MAX_ALLOWED  = GLIB_VERSION_2_32

  and a GLib header containing:

    void function_A (void) GLIB_DEPRECATED_IN_2_26;
    void function_B (void) GLIB_DEPRECATED_IN_2_28;
    void function_C (void) GLIB_DEPRECATED_IN_2_30;
    void function_D (void) GLIB_AVAILABLE_IN_2_32;
    void function_E (void) GLIB_AVAILABLE_IN_2_34;

  any application code using the above functions will get the following
  compiler warnings:

    function_A: deprecated symbol warning
    function_B: deprecated symbol warning
    function_C: no warning
    function_D: no warning
    function_E: undefined symbol warning

This means that it should be possible to gradually port code towards
non-deprecated API gradually, on a per-release basis.

https://bugzilla.gnome.org/show_bug.cgi?id=670542
configure.ac
docs/reference/glib/compiling.sgml
docs/reference/glib/glib-sections.txt
glib/Makefile.am
glib/docs.c
glib/glib.h
glib/gmacros.h
glib/gtypes.h
glib/gversion.c
glib/gversionmacros.h [new file with mode: 0644]