b4n left a comment (geany/geany-plugins#1476)
> I kind of hoped to define `-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_56`
> globally for all plugins and Geany because it would be useful but this
> produces warnings for functions provided by newer glib versions even if they
> are guarded by the corresponding `#if GLIB_CHECK_VERSION(...)` check. I'm not
> sure if there's a solution for this.
It would have been nice, but I'm afraid there's no solution to guarded code.
IIUC this works by tagging symbols as deprecated, and this can't track whether
the symbol is guarded against a specific version.
You can't even do something like
```c
#if GLIB_CHECK_VERSION(2, 60, 0)
# pragma push_macro("GLIB_VERSION_MAX_ALLOWED")
# undef GLIB_VERSION_MAX_ALLOWED
# define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_60
/* Your GLib 2.60 code */
# pragma pop_macro("GLIB_VERSION_MAX_ALLOWED")
#endif
```
because the symbol is already declared with the deprecation attribute upon
including the header.
A partial workaround could be:
```c
#if GLIB_CHECK_VERSION(2, 60, 0)
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/* Your GLib 2.60 code */
G_GNUC_END_IGNORE_DEPRECATIONS
#endif
```
But this will not check that you didn't use e.g. 2.62 code in that section.
So I'm afraid it's a lost cause… but maybe I'm wrong and somebody will think of
some clever solution.
--
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/pull/1476#issuecomment-3063809906
You are receiving this because you are subscribed to this thread.
Message ID: <geany/geany-plugins/pull/1476/[email protected]>