gpt4 book ai didi

包含功能 header 的 C++ 给出错误 '__dest' 未命名类型

转载 作者:行者123 更新时间:2023-12-02 10:15:29 24 4
gpt4 key购买 nike

我有一个曾经可以工作的 C++。但是,在包含 <functional> 之后 header ,编译失败并显示消息

c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\bits\std_function.h: In static member function 'static void std::_Function_base::_Base_manager<_Functor>::_M_clone(std::_Any_data&, const std::_Any_data&, std::true_type)':
c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\bits\std_function.h:167:11: error: '__dest' does not name a type
167 | ::new (__dest._M_access()) _Functor(__source._M_access<_Functor>());
| ^~~~~~
c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\bits\std_function.h:167:17: error: expected ')' before '.' token
167 | ::new (__dest._M_access()) _Functor(__source._M_access<_Functor>());
| ~ ^
| )

我使用的是 MinGW GCC 8.2.0,但它也出现在版本 9.2.0 中。

最佳答案

这是测试套件的一部分。原来是CppUTest做运算符重载导致的错误。重载是使用 -include/path/to/MemoryLeakDetectorNewMacros.h 包含的,因此仅查看代码并不直接明显。

使用 CppUTest 时的解决方案:确保 C++ STL header 包含在 CppUTest header MemoryLeakDetectorNewMacros.h 之前。查看CppUTest manual有关详细信息,请参阅“解决与 STL 的冲突”部分。

关于包含功能 header 的 C++ 给出错误 '__dest' 未命名类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62134550/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com