是否可以同时使用C ++ 11 ABI和cxx11样式字符串以及旧式字符串? [英] Is it possible to use C++11 ABI _and_ both cxx11-style and old-style strings?

查看:129
本文介绍了是否可以同时使用C ++ 11 ABI和cxx11样式字符串以及旧式字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码是在未设置_GLIBCXX_CXX11_ABI的情况下使用GCC 5.3.1构建的.现在,假设我想在同一代码中同时使用旧样式和新样式的 std :: __ cxx11 :: string .那可能吗?如果可以,怎么办?

I have some code which is being built with GCC 5.3.1 without _GLIBCXX_CXX11_ABI set. Now, suppose I want to use both old-style and new-style std::__cxx11::string's in the same bit of code . Is that possible? If so, how?

注意:

  • 我确实没有这样做的充分理由.我确实有一个不太好的理由,但是请让它成为一个理论上的问题.
  • 如果没有将C ++ 11字符串称为 std :: string .

推荐答案

可以在同一代码中同时使用旧的和新的 string 实现吗?不完全是.全能手册指出:

Can you have both the old and new string implementation in the same code? Not exactly. The Almighty Manual states:

ABI过渡使用以下命令添加了多个组件的新实现: abi_tag 属性和 __ cxx11 内联命名空间区分新实体和旧实体.

ABI transition adds new implementations of several components, using the abi_tag attribute and the __cxx11 inline namespace to distinguish the new entities from the old ones.

  • 可以通过 _GLIBCXX_USE_CXX11_ABI 每个翻译单元选择使用新的还是旧的ABI.

  • Use of the new or old ABI can be selected per-translation unit with the _GLIBCXX_USE_CXX11_ABI macro.

新的非引用计数字符串实现.

New non-reference-counted string implementation.

现在,从理论上讲,您可以使用 -D_GLIBCXX_USE_CXX11_ABI = 0 进行编译,并使用 ext/vstring.h ,这是GCC在中断ABI更改之前的符合标准的字符串实现.不过,如果事情破裂,我不会感到惊讶.

Now you could theoretically compile with -D_GLIBCXX_USE_CXX11_ABI=0 and use ext/vstring.h, which was GCC's conforming string implementation before the breaking ABI change. I wouldn't be surprised if things blew up, though.

这篇关于是否可以同时使用C ++ 11 ABI和cxx11样式字符串以及旧式字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆