@@ -632,20 +632,36 @@ def convert_header(
632632 # Remove these #defines as they don't make sense in C
633633 mod_remove_defines .apply (dom_root , ["IM_PLACEMENT_NEW(_PTR)" , "IM_NEW(_TYPE)" ])
634634 # Rewrite these defines to reference the new function names
635- # This could be done more generically but there are only three at present and there's a limit to how generic
635+ # This could be done more generically but there are only four at present and there's a limit to how generic
636636 # we can get (as there's all sorts of #define trickery that could break the general case), so for now we'll
637637 # just do it the easy way
638638 mod_rewrite_defines .apply (dom_root , [
639639 "IM_ALLOC(_SIZE)" ,
640640 "IM_FREE(_PTR)" ,
641- "IMGUI_CHECKVERSION()"
641+ "IMGUI_CHECKVERSION()" ,
642+ "IMGUI_DEBUG_LOG(...)"
642643 ], {"ImGui::" : "ImGui_" })
644+ # Also rewrite IMGUI_DEBUG_LOG_FONT to use ImGui_GetCurrentContext() instead of GImGui as the latter isn't
645+ # accessible from C
646+ mod_rewrite_defines .apply (dom_root , [
647+ "IMGUI_DEBUG_LOG_FONT(...)"
648+ ], {"GImGui" : "ImGui_GetCurrentContext()" })
643649 # Rename these to stop them generating compile warnings as they clash with those in imgui.h
644650 mod_rename_defines .apply (dom_root , {
645651 'IM_ALLOC(_SIZE)' : 'CIM_ALLOC(_SIZE)' ,
646652 'IM_FREE(_PTR)' : 'CIM_FREE(_PTR)' ,
647653 'IMGUI_CHECKVERSION()' : 'CIMGUI_CHECKVERSION()'
648654 })
655+ # Put these behind a guard to avoid spurious warnings
656+ mod_add_define_guards .apply (dom_root , [
657+ "IMGUI_DEBUG_LOG(...)" ,
658+ "IMGUI_DEBUG_LOG_FONT(...)" ,
659+ # We guard these specifically because although they are in theory the same, if the user has a slightly
660+ # mismatched version of the headers (i.e. C++ headers from one version but generated headers from another),
661+ # they will generate a warning.
662+ "IMGUI_VERSION_NUM" ,
663+ "IMGUI_VERSION"
664+ ], "DEAR_BINDINGS_INTERNAL_GLUE_CODE" )
649665
650666 mod_forward_declare_structs .apply (dom_root )
651667 mod_wrap_with_extern_c .apply (main_src_root ) # main_src_root here to avoid wrapping the config headers
0 commit comments