相关疑难解决方法(0)

使用stdlibc ++ 4.7启用C++ 11时,clang错误输出,而gcc编译正常

我一直在尝试让C++ 11工作,在浏览了不同的网站和Q/A之后,我仍然遇到了麻烦.我想和libstdc ++一起使用clang.它在clang状态中表示它受补丁支持 - http://clang.llvm.org/libstdc++4.7-clang11.patch.我从macports下载gcc4.7并在gcc4.7的头文件中做了相应的更改

我不使用libc ++的原因是因为libc ++和libstdc ++之间的ABI兼容性,由这个线程表示:为什么不能用c ++ 0x模式中的libc ++来链接这个boost :: program_options示例?

好的,一切都完成后,我使用以下代码测试了我的设置:

#include <mutex>
#include <thread>

int main ( ) {
    std::mutex myMutext;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我期待include应该在c ++ 11下工作.

所以这就是我用GCC编译它的方法

g++ -std=c++11 -I/opt/local/include/gcc47/c++ -L/opt/local/lib/gcc47 main.cpp -o main
Run Code Online (Sandbox Code Playgroud)

编译成功

与Clang

clang++ -std=c++11 -I/opt/local/include/gcc47/c++ -L/opt/local/lib/gcc47 main.cpp -o main
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

@work:boostTest$ clang++ -std=c++11 -I/opt/local/include/gcc47/c++ -L/opt/local/lib/gcc47 main.cpp -o main
In file included from main.cpp:1:
In file included from /opt/local/include/gcc47/c++/mutex:38:
In file included from /opt/local/include/gcc47/c++/tuple:37:
In file included from /opt/local/include/gcc47/c++/utility:70: …
Run Code Online (Sandbox Code Playgroud)

c++ macos gcc clang c++11

9
推荐指数
2
解决办法
2万
查看次数

标签 统计

c++ ×1

c++11 ×1

clang ×1

gcc ×1

macos ×1