mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 19:36:18 +01:00
5050298749
The public functions exposed as static inlines currently don't have annotations to describe when they were introduced. This means that compiling this file: #include <glib.h> void foo (void) { g_rec_mutex_locker_new (NULL); } with: gcc -c test.c \ -I/tmp/glib/include/glib-2.0 \ -I/tmp/glib/lib/x86_64-linux-gnu/glib-2.0/include \ -Werror \ -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_28 \ -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_28 will not produce any error message, despite using `g_rec_mutex_locker_new`, a function that was introduced after 2.28. This patch adds some annotations to all the publicly exposed static inline functions I could find. I could not use the existing G_AVAILABLE* macros, because they may expand to `extern`. This would then clash with the `static` keyword and produce: ../glib/gthread.h:397:1: error: multiple storage classes in declaration specifiers 397 | static inline GRecMutexLocker * | ^~~~~~ So I opted for adding a new set of macros, GLIB_AVAILABLE_STATIC_INLINE_IN_2_XY. With this patch applied, the example from above produces the expected warning: test.c: In function ‘foo’: test.c:5:3: error: ‘g_rec_mutex_locker_new’ is deprecated: Not available before 2.60 [-Werror=deprecated-declarations] 5 | g_rec_mutex_locker_new (NULL); | ^~~~~~~~~~~~~~~~~~~~~~ In file included from /tmp/glib/include/glib-2.0/glib/gasyncqueue.h:32, from /tmp/glib/include/glib-2.0/glib.h:32, from test.c:1: /tmp/glib/include/glib-2.0/glib/gthread.h:398:1: note: declared here 398 | g_rec_mutex_locker_new (GRecMutex *rec_mutex) | ^~~~~~~~~~~~~~~~~~~~~~
63 lines
2.0 KiB
Meson
63 lines
2.0 KiB
Meson
# The list of minor versions in the 2.x.x series which have had
|
|
# GLIB_AVAILABLE_IN_* macros. This should include the current unreleased stable
|
|
# version.
|
|
#
|
|
# FIXME: It would be good to be able to generate this list:
|
|
# https://github.com/mesonbuild/meson/issues/5026
|
|
stable_2_series_versions = [
|
|
'26', '28', '30', '32', '34', '36', '38',
|
|
'40', '42', '44', '46', '48', '50', '52', '54', '56', '58',
|
|
'60', '62', '64', '66',
|
|
]
|
|
|
|
ignore_decorators = [
|
|
'GLIB_VAR',
|
|
'G_GNUC_INTERNAL',
|
|
'G_GNUC_WARN_UNUSED_RESULT',
|
|
'GLIB_AVAILABLE_IN_ALL',
|
|
]
|
|
|
|
foreach version : stable_2_series_versions
|
|
ignore_decorators += [
|
|
# Note that gtkdoc is going to use those in regex, and the longest match
|
|
# must come first. That's why '_FOR()' variant comes first.
|
|
# gtkdoc special-case '()' and replace it by a regex matching a symbol name.
|
|
'GLIB_AVAILABLE_IN_2_' + version,
|
|
'GLIB_DEPRECATED_IN_2_' + version + '_FOR()',
|
|
'GLIB_DEPRECATED_IN_2_' + version,
|
|
|
|
'GLIB_AVAILABLE_STATIC_INLINE_IN_2_' + version,
|
|
|
|
'GLIB_AVAILABLE_ENUMERATOR_IN_2_' + version,
|
|
'GLIB_DEPRECATED_ENUMERATOR_IN_2_' + version + '_FOR()',
|
|
'GLIB_DEPRECATED_ENUMERATOR_IN_2_' + version,
|
|
|
|
'GLIB_AVAILABLE_MACRO_IN_2_' + version,
|
|
'GLIB_DEPRECATED_MACRO_IN_2_' + version + '_FOR()',
|
|
'GLIB_DEPRECATED_MACRO_IN_2_' + version,
|
|
|
|
'GLIB_AVAILABLE_TYPE_IN_2_' + version,
|
|
'GLIB_DEPRECATED_TYPE_IN_2_' + version + '_FOR()',
|
|
'GLIB_DEPRECATED_TYPE_IN_2_' + version,
|
|
]
|
|
endforeach
|
|
|
|
gtkdoc_common_scan_args = [
|
|
'--ignore-decorators=' + '|'.join(ignore_decorators),
|
|
]
|
|
|
|
if get_option('gtk_doc')
|
|
if not meson.version().version_compare('>=0.52.0')
|
|
error('Building documentation requires Meson >= 0.52.0.')
|
|
endif
|
|
# Check we have the minimum gtk-doc version required. Older versions won't
|
|
# generate correct documentation.
|
|
dependency('gtk-doc', version : '>=1.32',
|
|
fallback : ['gtk-doc', 'dummy_dep'],
|
|
default_options : ['tests=false'])
|
|
endif
|
|
|
|
subdir('gio')
|
|
subdir('glib')
|
|
subdir('gobject')
|