Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sokol_imgui.h: C++ error: member reference base type 'ImDrawList **' (aka 'struct ImDrawList **') is not a structure or union #72

Closed
Namek opened this issue Jul 7, 2024 · 3 comments

Comments

@Namek
Copy link

Namek commented Jul 7, 2024

Hi!

I have added sokol-zig to my project per this url in build.zig.zon: git+https://github.com/floooh/sokol-zig.git#ca76d1e66b2539a6614535aaad39d0168985a2e9

and then of course my build.zig:

const dep_sokol = b.dependency("sokol", .{
    .target = target,
    .optimize = optimize,
    .with_sokol_imgui = true,
});
dep_sokol.artifact("sokol_clib").addIncludePath(b.path("deps/")); // I have custom cimgui.h which includes the original "cimgui/cimgui.h" from there
exe.root_module.addImport("sokol", dep_sokol.module("sokol"));

And here I got some C++ error:

/Users/namek/.cache/zig/p/122055d69396139fc4b51ba859a2af304608e336572084ed44c5c79504be9ae2aba8/src/sokol/c/sokol_imgui.h:2587:35: error: member reference base type 'ImDrawList **' (aka 'struct ImDrawList **') is not a structure or union
        return draw_data->CmdLists.Data[cl_index];
               ~~~~~~~~~~~~~~~~~~~^~
/Users/namek/.cache/zig/p/122055d69396139fc4b51ba859a2af304608e336572084ed44c5c79504be9ae2aba8/src/sokol/c/sokol_imgui.c:9:10: note: in file included from /Users/namek/.cache/zig/p/122055d69396139fc4b51ba859a2af304608e336572084ed44c5c79504be9ae2aba8/src/sokol/c/sokol_imgui.c:9:
#include "sokol_imgui.h"
         ^

Any ideas what's wrong?

My (c)imgui is "1.89.7"

@Namek
Copy link
Author

Namek commented Jul 7, 2024

My custom cimgui.h:

#ifndef __IMGUI_ZIG__H
#define __IMGUI_ZIG__H

// without this ifndef it would error about redefining it
#ifndef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
  #define CIMGUI_DEFINE_ENUMS_AND_STRUCTS 1
#endif

#include "./cimgui/cimgui.h"

// because Zig doesn't support c.igGetCurrentWindow().*.DC.CursorPosPrevLine;
EXTERN ImGuiWindowTempData* igGetCurrentWindowRead_DC();
EXTERN ImGuiID igDockBuilderGetNodeID(ImGuiID node_id);

#endif

I tried including the original cimgui.h by doing the path change like this:

dep_sokol.artifact("sokol_clib").addIncludePath(b.path("deps/cimgui"));

so it would get the deps/cimgui/cimgui.h. The error stays the same.

It seems the error is about this place:

static ImDrawList* _simgui_imdrawlist_at(ImDrawData* draw_data, int cl_index) {
    #if defined(__cplusplus)
        return draw_data->CmdLists[cl_index];
    #else
        return draw_data->CmdLists.Data[cl_index];  // <!--- this line
    #endif
}

@floooh
Copy link
Owner

floooh commented Jul 8, 2024

This was a breaking change between cimgui 1.89 and 1.90, you basically need to update to a more recent ImGui version to use the sokol imgui bindings:

floooh/sokol@d4ac122#diff-cb6a37081b7b34f6ee0cc996c9a756b99a750ac7fde63297b57d23433a659b5c

@floooh floooh closed this as completed Jul 8, 2024
@floooh
Copy link
Owner

floooh commented Jul 8, 2024

PS: or rather the breakage seems to have been introduced in cimgui 1.89.9, not in 1.90

floooh/sokol#879

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants