! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Missing initializer for field 'interface_finalize' of 'GInterfaceInfo' in THU...
Status:
RESOLVED: FIXED
Priority:
Very Low
Severity:
trivial

Comments

Description jeinzi 2019-07-22 04:59:23 CEST
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!
Comment 1 alexxcons editbugs 2019-07-22 21:53:52 CEST
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 :)
Comment 2 jeinzi 2019-07-24 22:29:01 CEST
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
Comment 3 Git Bot editbugs 2019-07-30 04:15:41 CEST
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
Comment 4 Andre Miranda editbugs 2019-07-30 04:17:32 CEST
Using a designated initializer made the warning go away, much better than hackarounds to please the preprocessor.
Comment 5 Git Bot editbugs 2019-07-31 03:11:47 CEST
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
Comment 6 jeinzi 2019-08-01 00:37:14 CEST
I agree, good solution! :)
But I have to ask: Is GInterfaceInfo.interface_finalize set anywhere? Shouldn't that be done by that macro?
Comment 7 Andre Miranda editbugs 2019-08-02 05:46:33 CEST
(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.

Bug #15734

Reported by:
jeinzi
Reported on: 2019-07-22
Last modified on: 2019-08-02

People

Assignee:
Xfce Bug Triage
CC List:
3 users

Version

Attachments

Proposed patch (816 bytes, patch)
2019-07-24 22:29 CEST , jeinzi
jeinzi: review+

Additional information