Skip to content

gstdio: Silence "Not available before" warnings for inline functions

Simon McVittie requested to merge wip/smcv/autofd into main
  • gstdio: Warn if g_autofd is used with GLIB_VERSION_MAX_ALLOWED < 2.76

    Fixes: b3934133 "gstdio: Add g_clear_fd() and g_autofd"
    Helps: #2796 (closed)

  • gstdio: Silence "Not available before" warnings for inline functions

    Whenever a static inline calls a GLib function that was added since we started tracking versions, we need to silence the "Not available before" warnings, otherwise compiling code that includes this header with GLIB_VERSION_MAX_ALLOWED set to an old version will emit warnings, even if the static inline is never actually called.

    If the static inline is API, we also need to ensure it is annotated with GLIB_AVAILABLE_STATIC_INLINE_IN_2_76 or similar, so that callers get the appropriate "Not available before" warnings to alert them to their unintended use of newer API.

    g_clear_fd() calls a function that was introduced in 2.36. It already issues its own warning if called with GLIB_VERSION_MAX_ALLOWED less than 2.76.

    Similarly, g_autofd uses internal function _g_clear_fd_ignore_error which calls g_clear_fd(), but it issues its own warning if used with GLIB_VERSION_MAX_ALLOWED less than 2.76.

    Fixes: b3934133 "gstdio: Add g_clear_fd() and g_autofd"
    Resolves: #2796 (closed)

  • tests: Test that we can include all headers with an old MAX_VERSION

    In principle we could script this so that each max-version.c is compiled 26 times, once per possible MAX_VERSION, but I haven't implemented that here: just pinning to the oldest possible version is sufficient to reproduce #2796 (closed).

    These aren't included in the installed-tests, since they don't really do anything at runtime (the important thing is that they compile without warnings).

    Reproduces: #2796 (closed)

/cc @ebassi

Edited by Simon McVittie

Merge request reports