dearimgui / dear_bindings

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

Macros still use C++ syntax #69

Closed JROB774 closed 1 month ago

JROB774 commented 2 months ago

Whilst working on a custom ImGui backend in C, I noticed that macros defined in cimgui.h expand out to use the original C++ syntax, e.g:

#define IM_ALLOC(_SIZE)                     ImGui::MemAlloc(_SIZE)
#define IM_FREE(_PTR)                       ImGui::MemFree(_PTR)

Rather than the expected C syntax:

#define IM_ALLOC(_SIZE)                     ImGui_MemAlloc(_SIZE)
#define IM_FREE(_PTR)                       ImGui_MemFree(_PTR)
ShironekoBen commented 2 months ago

Oh, interesting - I'd somehow never actually spotted that but you're entirely right. Fixing that in the general case would be quite fiddly but there's only a handful by the looks of it so some special-case adjustments should do the trick. I'll try and put something in shortly to sort those out and report back here when it's done. Thanks for the report!

ShironekoBen commented 2 months ago

OK, I've added a simple fix to make those use the correct functions, and also renamed the macros to CIM_ALLOC and CIM_FREE so as to avoid compiler warnings when compiling code that also references imgui.h. Hopefully that fixes things for you - if run into any other problems please just let me know. Thanks again for the report!

JROB774 commented 2 months ago

Nice, thanks for looking into that, the changes look good! Just a heads up that I spotted the IMGUI_CHECKVERSION is still using the C++ syntax. I am not using that macro, so didn't flag/notice it initially, but it might be worth just fixing that one up as well for completeness. Other than that, I'm happy for the issue to be closed -- thanks again for the quick fix!

ShironekoBen commented 1 month ago

Good point, I'd overlooked that one - I've fixed it now too. Thanks!

JROB774 commented 1 month ago

Awesome, I'll close the issue now - thanks again. :)