Why nanobind can build this binding while pybind11 raises "use of undefined type"? #499
Unanswered
davidlatwe
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Sorry, I don't see how any of this is related to nanobind based on your description. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem
I found this when making a Python binding for ImGui - docking branch.
The problem starts from here, ImGui's
std::vector<>
-like class,sizeof()
is used:https://github.com/ocornut/imgui/blob/085781f5ca5372d5fc804d7e44b5bf27a8994af7/imgui.h#L2003
In its internal header,
ImVector
is used for storingImGuiDockNodeSettings
.https://github.com/ocornut/imgui/blob/085781f5ca5372d5fc804d7e44b5bf27a8994af7/imgui_internal.h#L1881
But the definition of
ImGuiDockNodeSettings
is inimgui.cpp
file:https://github.com/ocornut/imgui/blob/085781f5ca5372d5fc804d7e44b5bf27a8994af7/imgui.cpp#L15630
So when I build the binding with pybind11, Windows is complaining:
(strange that MSVC did not mention anything about
sizeof
and I thought it was becasue my cmake setup was incorrect.)And on Linux I saw:
Question
However, if I build the binding with nanobind, build was success and the binding works perfectly.
What magic did nanobind use?
I made a minimum reproducible repo for showcasing the issue: https://github.com/davidlatwe/py-binding-test
For my own ImGui binding work, I may tweak ImGui source code for pybind11, or just continue using nanobind. But I am really curious about "why this works".
P.S. The title of this thread feels not clear enough, welcome to change it.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions