I'm currently working on the [Dropbox plugin](https://github.com/Jeinzi/thunar-dropbox) for Thunar. I'm using this macro: > THUNARX_DEFINE_TYPE_WITH_CODE (TdpProvider, > tdp_provider, > G_TYPE_OBJECT, > THUNARX_IMPLEMENT_INTERFACE (THUNARX_TYPE_MENU_PROVIDER, > tdp_provider_menu_provider_init)) and I'm getting the following compiler warning: > warning: missing initializer for field ‘interface_finalize’ of ‘GInterfaceInfo’ {aka ‘const struct _GInterfaceInfo’} [-Wmissing-field-initializers] > 59 | THUNARX_DEFINE_TYPE_WITH_CODE (TdpProvider, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > In file included from /usr/include/glib-2.0/gobject/gobject.h:24, > from /usr/include/glib-2.0/gobject/gbinding.h:29, > from /usr/include/glib-2.0/glib-object.h:23, > from /usr/include/glib-2.0/gio/gioenums.h:28, > from /usr/include/glib-2.0/gio/giotypes.h:28, > from /usr/include/glib-2.0/gio/gio.h:26, > from /home/jeinzi/Programme/C/thunar-dropbox/src/tdp-provider.c:31: > /usr/include/glib-2.0/gobject/gtype.h:1083:26: note: ‘interface_finalize’ declared here > 1083 | GInterfaceFinalizeFunc interface_finalize; This is the part of the expanded macro that causes the warning: > static const GInterfaceInfo thunarx_implement_interface_info = { (GInterfaceInitFunc) (void (*)(void)) tdp_provider_menu_provider_init }; Steps to reproduce: git clone https://github.com/Jeinzi/thunar-dropbox.git cd thunar-dropbox git checkout dev-jeinzi cmake -B build -DCMAKE_BUILD_TYPE=Release . cmake --build build Opinions? I'm new here - should I submit a patch that initializes _GInterfaceInfo.interface_finalize to null? Thanks for your time!
Thanks for reporting ! Yes, a git patch usually is the way to go. That makes it simpler for me to give you the credits for the fix :)
Created attachment 8810 Proposed patch It turns out that the C preprocessor doesn't like commas in macro arguments when they are not between parenthesis, so I had to create two additional macros that defer the creation of the commas. See https://stackoverflow.com/a/49349949/3641597
Andre Miranda referenced this bugreport in commit fad90c557a3241ba8d574b05db8734bfd13f35cb Use designated initializer to avoid compile warnings (Bug #15734) https://git.xfce.org/xfce/thunar/commit?id=fad90c557a3241ba8d574b05db8734bfd13f35cb
Using a designated initializer made the warning go away, much better than hackarounds to please the preprocessor.
Andre Miranda referenced this bugreport in commit aba45988bad509bf6e51ae640c64926fe11ced6b Use designated initializer to avoid compile warnings (Bug #15734) https://git.xfce.org/xfce/thunar/commit?id=aba45988bad509bf6e51ae640c64926fe11ced6b
I agree, good solution! :) But I have to ask: Is GInterfaceInfo.interface_finalize set anywhere? Shouldn't that be done by that macro?
(In reply to jeinzi from comment #6) > I agree, good solution! :) > But I have to ask: Is GInterfaceInfo.interface_finalize set anywhere? > Shouldn't that be done by that macro? Honestly, I don't know. It's been like this since forever, I'm not going to change unless we have a reason.