gpt4 book ai didi

c++ - 是否可以同时使用 C++11 ABI _and_ cxx11 风格和旧式字符串?

转载 作者:行者123 更新时间:2023-11-28 05:38:49 27 4
gpt4 key购买 nike

我有一些代码是用 GCC 5.3.1 构建的,没有设置 _GLIBCXX_CXX11_ABI。现在,假设我想在同一段代码中同时使用旧式和新式 std::__cxx11::string。那可能吗?如果是,怎么办?

注意事项:

  • 我真的没有充分的理由这样做。我确实有一个不太充分的理由,但请让我们把它变成一个理论问题。
  • 如果 C++11 字符串不被称为 std::string 也没关系。

最佳答案

您能否在同一代码中同时使用旧的和新的 string 实现?不完全是。 Almighty Manual状态:

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.

  • 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 重大更改之前的一致字符串实现。不过,如果事情爆发了,我不会感到惊讶。

关于c++ - 是否可以同时使用 C++11 ABI _and_ cxx11 风格和旧式字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37623580/

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