从gcc 4.6.3移植到5.4.0的basic_string.h错误

时间:2018-04-26 12:02:46

标签: c++ string g++

重新发布(虽然当一些g ++输出行看起来有几百个字符时,格式化并不容易!)。

我有一个c ++程序,可以使用g ++版本4.6.3在Ubuntu 12.04上编译。我决定使用更新的O / S和g ++ - 但是我得到了一些奇怪的编译错误。现在我使用的是Ubuntu 16.04和g ++ 5.4.0。奇怪的是我得到的初始错误消息.cpp源文件没有指向应该生成该类型消息的一行代码。我看到的错误是:

 In file included from /usr/include/c++/5/string:52:0,
             from pkcs11_test.h:17,
             from pkcs11_attr.h:13,
             from pkcs11_attr.cpp:16:
 /usr/include/c++/5/bits/basic_string.h: In instantiation of ‘std::__cxx11::basic_string<_CharT, _Traits,
 _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) 
 [with _CharT = unsigned char; _Traits = std::char_traits<unsigned char>; _Alloc = sec_allocator<unsigned char>]’:
 pkcs11_attr.cpp:48:9:   required from here
 /usr/include/c++/5/bits/basic_string.h:399:62: error: no matching function for call to
 ‘std::__cxx11::basic_string<unsigned char, std::char_traits<unsigned char>, sec_allocator<unsigned char>
  >::_Alloc_hider::_Alloc_hider(std::__cxx11::basic_string<unsigned char, std::char_traits<unsigned char>,
  sec_allocator<unsigned char> >::pointer, const allocator_type&)’
   : _M_dataplus(_M_local_data(), __str._M_get_allocator()) // TODO A traits


 /usr/include/c++/5/bits/basic_string.h:108:2: note: candidate: std::__cxx11::basic_string<_CharT, _Traits,
 _Alloc>::_Alloc_hider::_Alloc_hider(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer, const _Alloc&) [with
 _CharT = unsigned char; _Traits = std::char_traits<unsigned char>; _Alloc = sec_allocator<unsigned char>;
 std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer = unsigned char*]
 _Alloc_hider(pointer __dat, const _Alloc& __a = _Alloc())


/usr/include/c++/5/bits/basic_string.h:108:2: note:   no known conversion for argument 2 from 
‘const allocator_type {aka const std::allocator<unsigned char>}’ to ‘const sec_allocator<unsigned char>&’
/usr/include/c++/5/bits/basic_string.h:106:14: note: candidate: std::__cxx11::basic_string<unsigned char,
 std::char_traits<unsigned char>, sec_allocator<unsigned char> >::_Alloc_hider::_Alloc_hider(const
 std::__cxx11::basic_string<unsigned char, std::char_traits<unsigned char>, sec_allocator<unsigned char>     >::_Alloc_hider&)
 struct _Alloc_hider : allocator_type // TODO check __is_final


/usr/include/c++/5/bits/basic_string.h:106:14: note:   candidate expects 1 argument, 2 provided
makefile:16: recipe for target 'pkcs11_attr.o' failed

make: *** [pkcs11_attr.o] Error 1

错误消息实际上并没有指向它指向return语句的合理行 - 如下所示。

代码是:

 byteString CkAttribute::asByteString () const {
     byteString retVal;

 if( pValue )
     copyCkBStringToBString( (unsigned char *)pValue, ulValueLen, retVal );
 // end if

  <<<<< error points to the below line>>>>
  return retVal;
}

12.04 Ubuntu是32位,新的16.04 Ubuntu是64位。但是我已经安装了g ++ multilib并尝试在新平台上使用-m32进行编译。但是,我得到完全相同的错误。我正在编译的程序非常庞大,包含超过12个.cpp源文件 - 所有这些文件编译得很好 - 这只是这个源文件中的一个错误。这让我很生气!

0 个答案:

没有答案