Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
iforce2d opened this issue May 11, 2024 · 2 comments
Open

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

iforce2d opened this issue May 11, 2024 · 2 comments

Comments

@iforce2d
Copy link

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>

@btzy
Copy link

btzy commented May 11, 2024

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_. 🤷

@iforce2d
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants