You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Binding fails on Windows using Ninja + Clang #1250
When trying to compile godot_cpp + my lib that includes godot_cpp using clang and ninja on Windows 11,
when calling
godot::ClassDB::bind_method(...)
I get a compile error
In file included from C:/Users/user/dev/project/GDClient/src/MyClass.h:11:
In file included from C:/Users/user/dev/project/build/libs/godot-cpp/gen/include\godot_cpp/classes/engine.hpp:43:
In file included from C:/Users/user/dev/project/libs/godot-cpp/include\godot_cpp/core/class_db.hpp:38:
C:/Users/user/dev/project/libs/godot-cpp/include\godot_cpp/core/method_bind.hpp:506:49: error: cannot reinterpret_cast from member pointer type 'godot::NodePath (MyClass::)()' to member pointer type 'godot::NodePath (godot::_gde_UnexistingClass::)()' of different size
MethodBind a = memnew((MethodBindTR<R, P...>)(reinterpret_cast<R (MB_T::)(P...)>(p_method)));
On Linux CMake + Ninja + Clang works flawlessly.
I tried to look where to issue could be occurring. I found out when I remove MSVC condition from CMakeLists.txt:157
from:
target_compile_definitions(${PROJECT_NAME} PUBLIC
$<$<CONFIG:Debug>:
DEBUG_ENABLED
DEBUG_METHODS_ENABLED
>
$<${compiler_is_msvc}:
TYPED_METHOD_BIND
/>
)
to:
target_compile_definitions(${PROJECT_NAME} PUBLIC
$<$<CONFIG:Debug>:
DEBUG_ENABLED
DEBUG_METHODS_ENABLED
>
TYPED_METHOD_BIND
)
This effectively resolved the errors and got a successful build.
Although I am not really sure if that fixes things properly and does not create issues elsewhere.
Steps to reproduce
Link godot_cpp to your library
Bind one of your methods using godot::ClassDB::bind_method
Run CMake with build system Ninja and compiler Clang
Activity
enetheru commentedon Sep 24, 2024
Note to self: Read linked merge requests before spending the morning looking into an issue.
I have successfully re-produced your error with a fresh download of llvm binaries.
"When Clang compiles C++ code for Windows, it attempts to be compatible with MSVC. There are multiple dimensions to compatibility." MSVCCompatibility
And the associated godotengine issue
adding TYPED_METHOD_BIND to the definitions solves the compile error
enetheru commentedon Nov 27, 2024
This will be resolved by PR #1651