nativefiledialog icon indicating copy to clipboard operation
nativefiledialog copied to clipboard

Crash if I call a variable 'g_log' (GTK3)

Open iforce2d opened this issue 9 months ago • 2 comments

I realize this is not a bug in nativefiledialog, but this just cost me MANY hours of intense frustration and confusion, so I'll mention it in case it helps someone else.

Simply having this anywhere will cause the nativefiledialog to crash every time:

int g_log;

The solution is to call your variables something other than g_log.

As a side note, I thought platform libraries were supposed to namespace or prefix their variables away properly so that collisions like this are extremely unlikely. Is it really such a surprise that the application programmer might want to name a variable g_log?? Couldn't the library at least make it glib2_log or something?? </rant>

iforce2d avatar May 11 '24 09:05 iforce2d

Do you know why the error occurs? I guess this could be some kind of issue where you have two different symbols of the same name and the linker assumes that they are the same symbol. Not trying to support GTK/GLib's naming convention but it seems that every single thing in GLib starts with g_. 🤷

btzy avatar May 11 '24 17:05 btzy

Yes, libglib-2.0.so includes the symbol g_log. I often prefix my global variables with g_, which hasn't been a problem for 30 years with every other library I've used. Fortunately the fix is very simple:

#define g_log somethingelse

iforce2d avatar May 12 '24 03:05 iforce2d