[glib/avoid-name-collisions] GResource compiler: Prefix static [con|de]strutors with c_name
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/avoid-name-collisions] GResource compiler: Prefix static [con|de]strutors with c_name
- Date: Mon, 26 Jul 2021 09:00:37 +0000 (UTC)
commit a947cc1c11f5daca4e1d677d5650993a6a3fa446
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Mon Jul 26 16:51:26 2021 +0800
GResource compiler: Prefix static [con|de]strutors with c_name
When attempting to test Windows support for building libadwaita, since we are
using multiple GResource files, one would hit linker errors where multiple
definitions of the following symbols have been defined, when
glib-compile-resources was invoked without manual register:
resource_constructor_wrapper
resource_destructor_constructor
_arrayresource_constructor
_arrayresource_destructor
In order to avoid that, just prefix the definitions of resource_constructor
and resource_destructor, like what we do when --manual-register is used, with
what we pass in with --c-name so that we ensure that we do not end up in such
name collisions.
gio/glib-compile-resources.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/gio/glib-compile-resources.c b/gio/glib-compile-resources.c
index db621a7b6..b6f67581f 100644
--- a/gio/glib-compile-resources.c
+++ b/gio/glib-compile-resources.c
@@ -1183,27 +1183,27 @@ main (int argc, char **argv)
"#ifdef G_HAS_CONSTRUCTORS\n"
"\n"
"#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA\n"
- "#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(resource_constructor)\n"
+ "#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(%sresource_constructor)\n"
"#endif\n"
- "G_DEFINE_CONSTRUCTOR(resource_constructor)\n"
+ "G_DEFINE_CONSTRUCTOR(%sresource_constructor)\n"
"#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA\n"
- "#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(resource_destructor)\n"
+ "#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(%sresource_destructor)\n"
"#endif\n"
- "G_DEFINE_DESTRUCTOR(resource_destructor)\n"
+ "G_DEFINE_DESTRUCTOR(%sresource_destructor)\n"
"\n"
"#else\n"
"#warning \"Constructor not supported on this compiler, linking in resources will not
work\"\n"
"#endif\n"
"\n"
- "static void resource_constructor (void)\n"
+ "static void %sresource_constructor (void)\n"
"{\n"
" g_static_resource_init (&static_resource);\n"
"}\n"
"\n"
- "static void resource_destructor (void)\n"
+ "static void %sresource_destructor (void)\n"
"{\n"
" g_static_resource_fini (&static_resource);\n"
- "}\n");
+ "}\n", c_name, c_name, c_name, c_name, c_name, c_name);
}
fclose (file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]