dearimgui / dear_bindings

C header (and language binding metadata) generator for Dear ImGui
MIT License
221 stars 12 forks source link

Improper use of `static` is preventing compilation with GCC/Clang #14

Closed PathogenDavid closed 2 years ago

PathogenDavid commented 2 years ago

The generator currently brings over static inline functions as static functions. This isn't correct in this context since the functions don't actually have internal linkage since they're never defined.

A side-effect of this is that cimgui.cpp fails to build with GCC and Clang because the expansion of CIMGUI_API results in extern "C" static, which is results in two conflicting linkage specifications. (MSVC seems to just ignore the extern "C" which is also not correct in this case.)

The fix should be as simple as removing this line entirely:

https://github.com/dearimgui/dear_bindings/blob/11d93d51fa924400b0b4feb38d91e3181c4d8ee9/src/templates/imgui-header.cpp#L7

It's not necessary to repeat extern "C" on every single function declaration when the header is wrapped in an extern "C" block. I also believe that specifying it on the declaration is enough, but you could wrap the cimgui.cpp implementations with an extern "C" block as well.

I also don't think it's correct to hard-code it here anyway since it prevents overriding CIMGUI_API to add __declspec on Windows.