Skip to content

Draft: gmacros: Fix G_GNUC_* attributes on clang-cl

Aleksandr Mezin requested to merge amezin/glib:clang-cl-attributes into master

Currently when GLib is being compiled with clang-cl, clang-cl emits a lot of warnings about unused functions and variables:

[583/750] Compiling C object gio/tests/modules/testmoduleb.dll.p/test-module-b.c.obj
../gio/tests/modules/test-module-b.c(39,1): warning: unused function 'test_b_get_instance_private' [-Wunused-function]
G_DEFINE_TYPE (TestB, test_b, G_TYPE_OBJECT)
^
..\gobject/gtype.h(1603,43): note: expanded from macro 'G_DEFINE_TYPE'
#define G_DEFINE_TYPE(TN, t_n, T_P)                         G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
                                                            ^
..\gobject/gtype.h(1762,60): note: expanded from macro 'G_DEFINE_TYPE_EXTENDED'
#define G_DEFINE_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_)      _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, _f_) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
                                                            ^
..\gobject/gtype.h(2034,3): note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN'
  _G_DEFINE_TYPE_EXTENDED_BEGIN_PRE(TypeName, type_name, TYPE_PARENT) \
  ^
..\gobject/gtype.h(1989,24): note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN_PRE'
static inline gpointer \
                       ^
<scratch space>(104,1): note: expanded from here
test_b_get_instance_private
^
1 warning generated.

This change removes all "unused" warnings, and GLib still compiles in both c_std=gnu99 (with G_STATIC_ASSERT fix) and c_std=gnu11 mode.

Edited by Aleksandr Mezin

Merge request reports