CLANG与GNU编译器集合-在GNU中编译,但在CLANG中失败

CLANG vs. GNU Compilers Collection - Compiles in GNU but fails in CLANG

本文关键字:GNU CLANG 编译 但在 失败 编译器 集合      更新时间:2023-10-16

我正试图用clang++在MAC OS X 10.9.5 Mavericks中使用第三方lib"ACE 6.2.8"编译我的项目。

我得到以下错误:

In file included from ../../../Client/Chromodoris/Agent/CacheGenerator.cpp:15:
In file included from ../../../Client/Chromodoris/Agent/ACEIncludes.h:22:
In file included from ../../../Client/Chromodoris/ExternalLibs/ACE_wrappers/ace/OS.h:53:
In file included from ../../../Client/Chromodoris/ExternalLibs/ACE_wrappers/ace/Cleanup.h:30:
In file included from ../../../Client/Chromodoris/ExternalLibs/ACE_wrappers/ace/Intrusive_List.h:128:
In file included from ../../../Client/Chromodoris/ExternalLibs/ACE_wrappers/ace/Intrusive_List.inl:5:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:627:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4013:35: error: no viable overloaded '='
            __e->__weak_this_ = *this;
            ~~~~~~~~~~~~~~~~~ ^ ~~~~~

CLANG++编译器可能有问题吗?有什么变通办法吗?

附加信息:

Moamen-MacBook:ace Moamen$ clang++ --version
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix

请注意,我的代码正在调用第三方lib(ACE),它在出现问题的地方调用CLANG++工具链。

请注意,相同的代码是在GNU编译器集合下编译的。我认为这个问题是相关的:根据标准,这些编译器中的哪一个有错误?

我找到了一个解决方法。

我收到了一条注释消息,在上面的错误后2-3行(对不起,没有消息!),告诉我不能从基类转换为派生类。

使用派生类对象而不是基类对象,这个问题应该得到解决。请注意,您可以使用基类而不是派生类,但这取决于您的实现和需求。