[gobject-introspection/th/undef-glib-version: 18/18] giscanner: undef "GLIB_VERSION_{MAX_ALLOWED, MIN_REQUIRED}" macros in generated C file
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/th/undef-glib-version: 18/18] giscanner: undef "GLIB_VERSION_{MAX_ALLOWED, MIN_REQUIRED}" macros in generated C file
- Date: Tue, 30 Aug 2022 06:58:23 +0000 (UTC)
commit 8f8a39b6f7408d0d5cdb882b4db9f3543e0a6d23
Author: Thomas Haller <thaller redhat com>
Date: Thu Apr 7 11:17:52 2022 +0200
giscanner: undef "GLIB_VERSION_{MAX_ALLOWED,MIN_REQUIRED}" macros in generated C file
When g-ir-scanner is used by another project, than that project might
have the GLIB_VERSION_* macros defined. This is useful to ensure that
only intended glib API is used.
The project might then also pass the CFLAGS to g-ir-scanner, without
filtering those defines out. This can lead to compiler warnings.
For example, NetworkManager sets the version macros to GLIB_VERSION_2_40
and thus gets these warnings
/NetworkManager/tmp-introspect66917zc4/NM-1.0.c: In function ‘dump_object_type’:
/NetworkManager/tmp-introspect66917zc4/NM-1.0.c:252:13: warning: Not available before 2.70
252 | if (G_TYPE_IS_FINAL (type))
| ^~~~~~~~~~~~~~~~~
/NetworkManager/tmp-introspect66917zc4/NM-1.0.c: In function ‘dump_fundamental_type’:
/NetworkManager/tmp-introspect66917zc4/NM-1.0.c:370:13: warning: Not available before 2.70
370 | if (G_TYPE_IS_FINAL (type))
| ^~~~~~~~~~~~~~~~~
But these warnings are not correct. The installed g-ir-scanner knows for which
glib version to generate code. Undefine the macros to avoid the warning.
giscanner/dumper.py | 4 ++++
1 file changed, 4 insertions(+)
---
diff --git a/giscanner/dumper.py b/giscanner/dumper.py
index 22afd61ef..74a494b8b 100644
--- a/giscanner/dumper.py
+++ b/giscanner/dumper.py
@@ -34,6 +34,10 @@ from .ccompiler import CCompiler
# we want to introspect, in order to call its get_type functions.
_PROGRAM_TEMPLATE = """/* This file is generated, do not edit */
+
+#undef GLIB_VERSION_MIN_REQUIRED
+#undef GLIB_VERSION_MAX_ALLOWED
+
#include <glib.h>
#include <string.h>
#include <stdlib.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]