Der*_*rek 4 c++ libstdc++ devtoolset rhel6 rhel7
我在 RHEL6 和 RHEL7 上安装了 gcc 5.2.1,看起来 _GLIBCXX_USE_CXX11_ABI 被禁用了。即使我手动运行它也不起作用-D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14
。这意味着我不会获得小字符串优化功能。例如,以下代码的输出始终为 8 和“micro not set”。对于 SSO,如果我们查看代码 bits/basic_string.h,std::string 的大小应至少为 16。有什么解决办法吗?
#include <string>
#include <iostream>
int main()
{
std::cout << sizeof(std::string) << std::endl;
#if _GLIBCXX_USE_CXX11_ABI
std::cout << "macro set" << std::endl;
#else
std::cout << "macro not set" << std::endl;
#endif
}
Run Code Online (Sandbox Code Playgroud)
bugzilla.redhat有以下回复
雅库布·耶利内克 2018-02-19 06:08:00 美国东部时间
我们已经尽力了,但是无论是在 RHEL6 还是在 RHEL7 上都不可能支持这一点,这就是它被强制禁用的原因。它可以在 RHEL8 中工作(并且也是默认的)。