大家好!在WIN7、VS2017中编译加模块spine-godot的godot353,编译出错,请求帮助。
spine-cpp/src/spine/InheritTimeline.cpp,最后一句bone->_inherit = (Inherit) _frames[idx];编译出错:不能float...枚举...(以前的编译)。
删除此句,能编译出godot353.exe,运行spine_example暂无异常。
在WIN7、VS2017中编译加模块spine-godot的godot353,编译出错,请求帮助。
你好!在WIN7和VS2017中编译带有spine-godot模块的Godot 3.5.3时遇到编译错误,可能是由于类型转换问题。具体来说,错误出现在spine-cpp/src/spine/InheritTimeline.cpp
文件的最后一句:
bone->_inherit = (Inherit) _frames[idx];
编译错误提示不能将float
转换为枚举类型Inherit
。这是因为_frames[idx]
是一个float
类型,而Inherit
是一个枚举类型。
你可以尝试以下解决方案:
显式类型转换:确保类型转换是显式的,并且符合C++标准。你可以尝试使用
static_cast
进行类型转换:bone->_inherit = static_cast<Inherit>(_frames[idx]);
检查枚举定义:确保
Inherit
枚举类型的定义是正确的,并且与_frames[idx]
的值范围兼容。调试和日志记录:在编译前添加一些调试信息,确保
_frames[idx]
的值在预期范围内。例如:std::cout << "Frame value: " << _frames[idx] << std::endl; bone->_inherit = static_cast<Inherit>(_frames[idx]);
更新依赖项:确保你使用的是最新版本的spine-cpp和spine-godot模块,可能已经修复了相关问题。
如果删除该行代码后能够成功编译并运行godot353.exe
且没有异常,这可能是一个临时解决方案,但建议进一步检查代码逻辑,以确保不会引入其他潜在问题。
希望这些建议能帮助你解决编译问题!
a month later
按以下才能编译成功:
int nT=(int)frames[idx];
bone->inherit = static_cast<Inherit>(nT);
I've opened an issue for this here:
EsotericSoftware/spine-runtimes2645
6 days later
This has been fixed in the 4.2 branch of the spine-runtimes. Thanks for reporting!