将std :: __ cxx11 :: string转换为std :: string [英] Converting std::__cxx11::string to std::string

查看:4229
本文介绍了将std :: __ cxx11 :: string转换为std :: string的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用c + + 11,但也有一些库没有配置它,需要一些类型转换。特别是我需要一种方法将 std :: __ cxx11 :: string 转换为常规 std :: string ,但googling我找不到一个办法做这个,并把(string)在前面不工作。



如果我不转换我得到链接器错误,像这样:

 未定义的引用`H5 :: CompType :: insertMember __cxx11 :: basic_string< char,std :: char_traits< char>,std :: allocator< char>> const& unsigned long,H5 :: DataType const&)const'


解决方案

是否可能使用GCC 5?


如果你得到关于未定义的涉及std :: __ cxx11命名空间中的类型或标签[abi:cxx11]的符号的链接器错误,那么它可能表示你正在尝试链接对象使用_GLIBCXX_USE_CXX11_ABI宏的不同值编译的文件。这通常发生在链接到使用旧版本的GCC编译的第三方库时。如果第三方库无法使用新的ABI重建,则需要使用旧的ABI重新编译代码。


源: GCC 5版本说明/ Dual ABI



定义之前包括任何标准库头文件的宏应该可以解决您的问题: #define _GLIBCXX_USE_CXX11_ABI 0


I use c++11, but also some libraries that are not configured for it, and need some type conversion. In particular I need a way to convert std::__cxx11::string to regular std::string, but googling I can't find a way to do this and putting (string) in front does not work.

If I do not convert I get linker errors like this:

undefined reference to `H5::CompType::insertMember(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, H5::DataType const&) const'

解决方案

Is it possible that you are using GCC 5?

If you get linker errors about undefined references to symbols that involve types in the std::__cxx11 namespace or the tag [abi:cxx11] then it probably indicates that you are trying to link together object files that were compiled with different values for the _GLIBCXX_USE_CXX11_ABI macro. This commonly happens when linking to a third-party library that was compiled with an older version of GCC. If the third-party library cannot be rebuilt with the new ABI then you will need to recompile your code with the old ABI.

Source: GCC 5 Release Notes/Dual ABI

Defining the following macro before including any standard library headers should fix your problem: #define _GLIBCXX_USE_CXX11_ABI 0

这篇关于将std :: __ cxx11 :: string转换为std :: string的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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