一年多来,我一直在使用Boost的Bimap作为库存系统的基础。
typedef boost::bimap<boost::bimaps::set_of<uint32>,
boost::bimaps::multiset_of<uint32>,
boost::bimaps::with_info<FItemDetails>> InventoryBimap;
在从Unreal 4升级到Unreal 5之后,我做了一些其他的改动,从Boost 1.68.0升级到1.79.0,从C17升级到C20。
编辑:对不起,我忘了包括我正在使用Visual Studio 2022。
有两个来源的一堆编译错误,阻止我的游戏编译:
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\pointer_traits.hpp(120): error C2988: unrecognizable template declaration/definition
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\pointer_traits.hpp(127): note: see reference to class template instantiation 'boost::detail::ptr_to_expr<T,E>' being compiled
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\pointer_traits.hpp(120): error C2059: syntax error: '<end Parse>'
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\pointer_traits.hpp(120): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\pointer_traits.hpp(120): error C2988: unrecognizable template declaration/definition
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\pointer_traits.hpp(120): error C2059: syntax error: '->'
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\pointer_traits.hpp(120): error C2238: unexpected token(s) preceding ';'
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\pointer_traits.hpp(123): error C2988: unrecognizable template declaration/definition
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\pointer_traits.hpp(123): error C2059: syntax error: '<end Parse>'
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\pointer_traits.hpp(123): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
然后:
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\allocator_access.hpp(397): error C2988: unrecognizable template declaration/definition
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\allocator_access.hpp(407): note: see reference to class template instantiation 'boost::detail::alloc_has_allocate<A>' being compiled
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\allocator_access.hpp(397): error C2059: syntax error: '<end Parse>'
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\allocator_access.hpp(397): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\allocator_access.hpp(398): error C2988: unrecognizable template declaration/definition
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\allocator_access.hpp(398): error C2059: syntax error: '->'
1>H:\UnrealEngine\Engine\Source\ThirdParty\boost\boost-1_79_0\include\boost\core\allocator_access.hpp(400): error C2238: unexpected token(s) preceding ';'
第二个错误会在allocator_access. hpp中的每个模板上重复出现。
到目前为止,我发现的唯一短期修复方法是注解掉项目中包含的所有bimap。
我目前不确定如何进行,并希望有人有一些洞察力可能会发生什么。
2条答案
按热度按时间6yoyoihd1#
所以,我找到了答案。我在这里分享一下,让大家都知道:
在pointer_traits.hpp中,模板有两个函数:
我突然注意到了这个名字:“检查”。
“check”是一个Unreal宏名称,强制虚幻引擎在调用时崩溃(除非附加调试器)。因此,* 看起来 * 正常的函数调用被解释为调用Unreal的check宏,并导致编译失败。
所以我不得不在整个Boost中将“check”重命名为其他名称。这修复了编译错误,我的库存系统又开始工作了。
nc1teljy2#
我也遇到过这个问题,PosoKhov的解决方案是最快和最干净的。分叉UE repo和修改宏很快变得混乱,因为它似乎也在插件中引用。