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

发布于 2024-12-28 20:31:54 字数 1449 浏览 5 评论 0原文

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

libc++ 已安装,它可以工作,并且编译的程序(当它工作时)确实需要它。然而,编译器仍然试图通过扰乱命名空间来利用每一个机会使用 libstdc++ 版本; std::__1::mapstd::__1::basic_string 等等。现在,我从知道这个问题 为什么会发生这种情况,以及 libc++ 为什么会这样做。我只需要知道如何删除它,因为它完全不适用 - 我真的非常想使用 libc++ 版本,并且我的代码中没有任何内容需要这两种类型共存。

我尝试将 libstdc++ 文件夹从包含路径中取出,但失败了,导致它们完全无法访问。运气不好。我没有使用任何附加库,仅使用内置的 Linux/POSIX 标头(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

After substantial effort getting clang and libc++ to compile, run, integrate with NetBeans, and even cross-compile to a 32-bit machine, I thought I had it all figured out! So I go to use some features that libstdc++ didn't have (the entire reason for turning my dev environment upside down), and discover... I can't actually do that.

libc++ is installed, it works, and the compiled program (when it works) does require it. However, the compiler still tries to use libstdc++ versions at every opportunity, by messing with the namespace; std::__1::map, std::__1::basic_string, and so on. Now, I know from this question why that happens, and why libc++ does it. I just need to know how to obliterate it, because it's completely inapplicable - I really, truly do want to use the libc++ versions, and there is nothing in my code that would require the two types to coexist.

I've tried taking the libstdc++ folders out of the include path, and, failing, that, made them completely inaccessible. No luck. I'm not using any add-on libraries, only built-in Linux/POSIX headers (errno, socket, syslog, fcntl).

EDIT: Error message:

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> > >'

The libstdc++ map does not have emplace(). The libc++ version does.

The following invocation, from the command line, seems to work:

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

The invocation from within NetBeans does not:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空袭的梦i 2025-01-04 20:31:54

来自评论:

阿拉克尼德:
您的 NetBeans 调用没有 -std=c++0x,是否不需要? std::map::emplace 是一个 C++11 方法。

DigitalMan (OP):
@araqnid 确实做到了! Clang 抱怨该参数未被使用 - 事实上,即使它被使用和需要,仍然如此 - 因此我将其从 NetBeans 配置中删除。当然,错误的警告比完全的错误要好。

From the comments:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文