dearimgui / dear_bindings

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

Errors when compiling generated backend for D3D12 #49

Closed shawnhatori closed 8 months ago

shawnhatori commented 8 months ago

Here's the output for python dear_bindings\dear_bindings.py --backend imgui\backends\imgui_impl_dx12.h -o cimgui_impl_dx12:

Dear Bindings: parse Dear ImGui headers, convert to C and output metadata.
Parsing [path]\imconfig.h
Parsing [path]\imgui_impl_dx12.h
Storing unmodified DOM
Applying modifiers
Writing output to cimgui_impl_dx12[.h/.cpp/.json]
Done

Looks good. When I go to compile (static lib via MSVC) however, I get the following errors:

imgui.cpp
imgui_demo.cpp
imgui_draw.cpp
imgui_impl_dx12.cpp
imgui_impl_win32.cpp
imgui_tables.cpp
imgui_widgets.cpp
cimgui.cpp
cimgui_impl_dx12.cpp
cimgui_impl_dx12.cpp(22): error C2027: use of undefined type 'cimgui::D3D12_CPU_DESCRIPTOR_HANDLE_t'
[path]\cimgui_impl_dx12.h(35): note: see declaration of 'cimgui::D3D12_CPU_DESCRIPTOR_HANDLE_t'
cimgui_impl_dx12.cpp(22): error C2027: use of undefined type 'cimgui::D3D12_GPU_DESCRIPTOR_HANDLE_t'
[path]\cimgui_impl_dx12.h(36): note: see declaration of 'cimgui::D3D12_GPU_DESCRIPTOR_HANDLE_t'
cimgui_impl_dx12.cpp(24): error C2440: 'reinterpret_cast': cannot convert from 'cimgui::D3D12_CPU_DESCRIPTOR_HANDLE' to 'D3D12_CPU_DESCRIPTOR_HANDLE'
cimgui_impl_dx12.cpp(24): note: Conversion requires a constructor or user-defined-conversion operator, which can't be used by const_cast or reinterpret_cast
cimgui_impl_dx12.cpp(24): error C2440: 'reinterpret_cast': cannot convert from 'cimgui::D3D12_GPU_DESCRIPTOR_HANDLE' to 'D3D12_GPU_DESCRIPTOR_HANDLE'
cimgui_impl_dx12.cpp(24): note: Conversion requires a constructor or user-defined-conversion operator, which can't be used by const_cast or reinterpret_cast
cimgui_impl_dx12.cpp(24): error C2660: 'ImGui_ImplDX12_Init': function does not take 4 arguments
[path]\imgui_impl_dx12.h(34): note: see declaration of 'ImGui_ImplDX12_Init'
cimgui_impl_dx12.cpp(24): note: while trying to match the argument list '(ID3D12Device *, int, DXGI_FORMAT, ID3D12DescriptorHeap *)'
cimgui_impl_win32.cpp
Generating Code...
ShironekoBen commented 8 months ago

OK, I've added a workaround for the casting of those types, which I think means this should work now.

shawnhatori commented 8 months ago

This compiles successfully now, thank you!