gpt4 book ai didi

c++ - libc++ - 停止将 std 重命名为 std::__1?

转载 作者:可可西里 更新时间:2023-11-01 16:21:47 26 4
gpt4 key购买 nike

经过大量努力让 clang 和 libc++ 编译、运行、与 NetBeans 集成,甚至交叉编译到 32 位机器,我想我已经搞清楚了!因此,我开始使用 libstdc++ 没有的一些功能(这就是颠覆我的开发环境的全部原因),然后发现……我实际上做不到。

libc++ 已安装,它可以工作,编译的程序(当它工作时)确实需要它。但是,编译器仍然试图通过混淆命名空间来尝试使用 libstdc++ 版本; std::__1::mapstd::__1::basic_string 等。现在,我从this question知道为什么会这样,为什么 libc++ 会这样。我只需要知道如何抹杀它,因为它完全不适用——我真的非常想使用 libc++ 版本,而且我的代码中没有任何内容需要这两种类型共存。

我已经尝试将 libstdc++ 文件夹从包含路径中取出,但失败了,使它们完全无法访问。没运气。我没有使用任何附加库,仅使用内置的 Linux/POSIX header (errno、socket、syslog、fcntl)。

编辑:错误信息:

CoreCache.cpp:61:12: error: no member named 'emplace' in 'std::__1::map<std::__1::basic_string<char>, CacheEntry, std::__1::less<std::__1::basic_string<char> >, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char>, CacheEntry> > >'

libstdc++ 映射没有 emplace()。 libc++ 版本可以

以下命令行调用似乎有效:

clang++ -o stachecache -I /usr/local/lib/clang/3.1/include/ -I /usr/include/c++/v1/ -std=c++0x -stdlib=libc++ ./*.cpp

NetBeans 中的调用不会:

clang++ -stdlib=libc++ -O3   -c -O3 -Werror -MMD -MP -MF build/Release/clang-Linux-x86/CoreCache.o.d -o build/Release/clang-Linux-x86/CoreCache.o CoreCache.cpp

最佳答案

来自评论:

araqnid: Your NetBeans invocation doesn't have -std=c++0x, is it not needed? std::map::emplace is a C++11 method.

DigitalMan (OP): @araqnid That actually did it! Clang complained about that argument being unused - and still does, in fact, even when it's used and required - so I had taken it out of the NetBeans configuration. A faulty warning is better than a complete error, certainly.

关于c++ - libc++ - 停止将 std 重命名为 std::__1?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9000816/

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