I'm trying to include dear imgui in my project straight from the repo. Here's my build code
exe.addIncludePath(b.path("external/imgui"));
exe.addIncludePath(b.path("external/imgui/backends"));
exe.addCSourceFiles(.{
.root = b.path("external/imgui"),
.flags = &.{"-std=c++11"},
.files = &[_][]const u8{
"imgui.cpp",
"imgui_draw.cpp",
"imgui_tables.cpp",
"imgui_widgets.cpp",
"backends/imgui_impl_sdl3.cpp",
"backends/imgui_impl_sdlgpu3.cpp",
},
});
exe.linkLibCpp();
But when I try to include the headers
pub const imgui = @cImport({
@cInclude("imgui.h");
@cInclude("imgui_impl_sdl3.h");
@cInclude("imgui_impl_sdlgpu3.h");
});
I see errors that make it look like it's trying to use this as C, not C++ code
Diagnostics:
1. C import failed
2. must use 'struct' tag to refer to type 'ImGuiInputTextCallbackData'
3. must use 'struct' tag to refer to type 'ImGuiSizeCallbackData'
4. unknown type name 'constexpr'
5. call to undeclared function 'x'; ISO C99 and later do not support implicit function declarations
6. expected parameter declarator
7. expected ')'
8. duplicate member 'y'
9. expected ';' at end of declaration list
I thought that by adding .flags = &.{"-std=c++11"}, it would force this code to be built as c++, but maybe I'm missing something here