【问题标题】:How to compile boost 1.56 multiprecision on AIX 6.1 w/o C++11如何在没有 C++11 的 AIX 6.1 上编译 boost 1.56 多精度
【发布时间】:2016-06-23 02:41:55
【问题描述】:

我想在 AIX 6.1 中编译多精度提升库。 编译器不支持最新的C++,所以我定义了一些宏来使用旧的语法。

#include <boost/optional.hpp>

#define __IBMCPP_TR1__ 1
#define BOOST_NO_CXX11_RVALUE_REFERENCES 1
#define BOOST_NO_CXX11_VARIADIC_TEMPLATES 1
#define BOOST_NO_CXX11_USER_DEFINED_LITERALS 1
#define BOOST_NO_CXX11_CONSTEXPR 1
#define BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS 1
#define BOOST_NO_CXX11_HDR_ARRAY 1

#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

int* foo(double *xarr) {
    using boost::multiprecision::cpp_int;

    cpp_int i, j, k;
    j = i + k;

    using boost::multiprecision::cpp_dec_float;
    typedef boost::multiprecision::number<cpp_dec_float<53> > 
        cpp_bin_float_53;

    cpp_bin_float_53 a, b, c;
    a = b + c;
    return NULL;
}

最终我得到了以下错误。它主要抱怨在 std::reverse_iterator 之间找不到 != 的定义。这是否意味着我应该通过使用一些宏来关闭更多的 C++ 语法?谢谢,

"../../../../../../include/boost/integer_traits.hpp", line 83.56: 1540-0724 (W) The non-type template argument "-1" of type "T" has wrapped.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.23: 1540-0218 (S) The call does not match any parameter list for "operator!=".
"../../../../../../include/boost/multiprecision/detail/number_compare.hpp", line 145.13: 1540-1283 (I) "template <class Backend, expression_template_option ExpressionTemplates> boost::multiprecision::operator!=(const number<Backend,ExpressionTemplates> &, const number<Backend,ExpressionTemplates> &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.10: 1540-0288 (I) The function template parameter of type "const number<Backend,ExpressionTemplates> &" cannot be initialized with an argument of type "const std::reverse_iterator<std::_Ptrit<char,long,const char *,const char &,char *,char &> >".
"../../../../../../include/boost/multiprecision/detail/number_compare.hpp", line 152.4: 1540-1283 (I) "template <class Backend, expression_template_option ExpressionTemplates, class Arithmetic> boost::multiprecision::operator!=(const number<Backend,ExpressionTemplates> &, const Arithmetic &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.10: 1540-0288 (I) The function template parameter of type "const number<Backend,ExpressionTemplates> &" cannot be initialized with an argument of type "const std::reverse_iterator<std::_Ptrit<char,long,const char *,const char &,char *,char &> >".
"../../../../../../include/boost/multiprecision/detail/number_compare.hpp", line 159.4: 1540-1283 (I) "template <class Arithmetic, class Backend, expression_template_option ExpressionTemplates> boost::multiprecision::operator!=(const Arithmetic &, const number<Backend,ExpressionTemplates> &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.36: 1540-0288 (I) The function template parameter of type "const number<Backend,ExpressionTemplates> &" cannot be initialized with an argument of type "std::reverse_iterator<std::_Ptrit<char,long,char *,char &,char *,char &> >".
"../../../../../../include/boost/multiprecision/detail/number_compare.hpp", line 166.4: 1540-1283 (I) "template <class Arithmetic, class Tag, class A1, class A2, class A3, class A4> boost::multiprecision::operator!=(const Arithmetic &, const expression<Tag,A1,A2,A3,A4> &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.36: 1540-0288 (I) The function template parameter of type "const expression<Tag,A1,A2,A3,A4> &" cannot be initialized with an argument of type "std::reverse_iterator<std::_Ptrit<char,long,char *,char &,char *,char &> >".
"../../../../../../include/boost/multiprecision/detail/number_compare.hpp", line 175.4: 1540-1283 (I) "template <class Tag, class A1, class A2, class A3, class A4, class Arithmetic> boost::multiprecision::operator!=(const expression<Tag,A1,A2,A3,A4> &, const Arithmetic &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.10: 1540-0288 (I) The function template parameter of type "const expression<Tag,A1,A2,A3,A4> &" cannot be initialized with an argument of type "const std::reverse_iterator<std::_Ptrit<char,long,const char *,const char &,char *,char &> >".
"../../../../../../include/boost/multiprecision/detail/number_compare.hpp", line 184.4: 1540-1283 (I) "template <class Tag, class A1, class A2, class A3, class A4, class Tagb, class A1b, class A2b, class A3b, class A4b> boost::multiprecision::operator!=(const expression<Tag,A1,A2,A3,A4> &, const expression<Tagb,A1b,A2b,A3b,A4b> &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.10: 1540-0288 (I) The function template parameter of type "const expression<Tag,A1,A2,A3,A4> &" cannot be initialized with an argument of type "const std::reverse_iterator<std::_Ptrit<char,long,const char *,const char &,char *,char &> >".
"/usr/vacpp/include/utility", line 90.14: 1540-1283 (I) "template <class _T1, class _T2> std::operator!=(const pair<_T1,_T2> &, const pair<_T1,_T2> &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.10: 1540-0288 (I) The function template parameter of type "const pair<_T1,_T2> &" cannot be initialized with an argument of type "const std::reverse_iterator<std::_Ptrit<char,long,const char *,const char &,char *,char &> >".
"/usr/vacpp/include/xutility", line 321.14: 1540-1283 (I) "template <class _Ty, class _D, class _Pt, class _Rt, class _Pt2, class _Rt2> std::operator!=(const _Ptrit<_Ty,_D,_Pt,_Rt,_Pt,_Rt> &, const _Ptrit<_Ty,_D,_Pt2,_Rt2,_Pt,_Rt> &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.10: 1540-0288 (I) The function template parameter of type "const _Ptrit<_Ty,_D,_Pt,_Rt,_Pt,_Rt> &" cannot be initialized with an argument of type "const std::reverse_iterator<std::_Ptrit<char,long,const char *,const char &,char *,char &> >".
"/usr/vacpp/include/xutility", line 468.14: 1540-1283 (I) "template <class _RI> std::operator!=(const reverse_iterator<_RI> &, const reverse_iterator<_RI> &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.23: 1540-0290 (I) The function template parameter "_RI" has been found to have two values: "std::_Ptrit<char,long,const char *,const char &,char *,char &>" and "std::_Ptrit<char,long,char *,char &,char *,char &>".
"/usr/vacpp/include/xutility", line 630.14: 1540-1283 (I) "template <class _E, class _Tr> std::operator!=(const istreambuf_iterator<_E,_Tr> &, const istreambuf_iterator<_E,_Tr> &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.10: 1540-0288 (I) The function template parameter of type "const istreambuf_iterator<_E,_Tr> &" cannot be initialized with an argument of type "const std::reverse_iterator<std::_Ptrit<char,long,const char *,const char &,char *,char &> >".
"/usr/vacpp/include/iterator", line 197.14: 1540-1283 (I) "template <class _Ty, class _E, class _Tr, class _Dist> std::operator!=(const istream_iterator<_Ty,_E,_Tr,_Dist> &, const istream_iterator<_Ty,_E,_Tr,_Dist> &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.10: 1540-0288 (I) The function template parameter of type "const istream_iterator<_Ty,_E,_Tr,_Dist> &" cannot be initialized with an argument of type "const std::reverse_iterator<std::_Ptrit<char,long,const char *,const char &,char *,char &> >".
"/usr/vacpp/include/xmemory", line 433.14: 1540-1283 (I) "template <class _Ty, class _U> std::operator!=(const allocator<_Ty> &, const allocator<_U> &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.10: 1540-0288 (I) The function template parameter of type "const allocator<_Ty> &" cannot be initialized with an argument of type "const std::reverse_iterator<std::_Ptrit<char,long,const char *,const char &,char *,char &> >".
"/usr/vacpp/include/string", line 120.14: 1540-1283 (I) "template <class _E, class _Tr, class _A> std::operator!=(const basic_string<_E,_Tr,_A> &, const basic_string<_E,_Tr,_A> &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.10: 1540-0288 (I) The function template parameter of type "const basic_string<_E,_Tr,_A> &" cannot be initialized with an argument of type "const std::reverse_iterator<std::_Ptrit<char,long,const char *,const char &,char *,char &> >".
"/usr/vacpp/include/string", line 124.14: 1540-1283 (I) "template <class _E, class _Tr, class _A> std::operator!=(const _E *, const basic_string<_E,_Tr,_A> &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.10: 1540-0288 (I) The function template parameter of type "const _E *" cannot be initialized with an argument of type "const std::reverse_iterator<std::_Ptrit<char,long,const char *,const char &,char *,char &> >".
"/usr/vacpp/include/string", line 128.14: 1540-1283 (I) "template <class _E, class _Tr, class _A> std::operator!=(const basic_string<_E,_Tr,_A> &, const _E *)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.10: 1540-0288 (I) The function template parameter of type "const basic_string<_E,_Tr,_A> &" cannot be initialized with an argument of type "const std::reverse_iterator<std::_Ptrit<char,long,const char *,const char &,char *,char &> >".
"/usr/vacpp/include/vector", line 807.14: 1540-1283 (I) "template <class _Ty, class _A> std::operator!=(const vector<_Ty,_A> &, const vector<_Ty,_A> &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.10: 1540-0288 (I) The function template parameter of type "const vector<_Ty,_A> &" cannot be initialized with an argument of type "const std::reverse_iterator<std::_Ptrit<char,long,const char *,const char &,char *,char &> >".
"/usr/vacpp/include/xcomplex", line 261.14: 1540-1283 (I) "template <class _Ty> std::operator!=(const complex<_Ty> &, const complex<_Ty> &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.10: 1540-0288 (I) The function template parameter of type "const complex<_Ty> &" cannot be initialized with an argument of type "const std::reverse_iterator<std::_Ptrit<char,long,const char *,const char &,char *,char &> >".
"/usr/vacpp/include/xcomplex", line 265.14: 1540-1283 (I) "template <class _Ty> std::operator!=(const complex<_Ty> &, const _Ty &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.10: 1540-0288 (I) The function template parameter of type "const complex<_Ty> &" cannot be initialized with an argument of type "const std::reverse_iterator<std::_Ptrit<char,long,const char *,const char &,char *,char &> >".
"/usr/vacpp/include/xcomplex", line 269.14: 1540-1283 (I) "template <class _Ty> std::operator!=(const _Ty &, const complex<_Ty> &)" is not a viable candidate.
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1966.36: 1540-0288 (I) The function template parameter of type "const complex<_Ty> &" cannot be initialized with an argument of type "std::reverse_iterator<std::_Ptrit<char,long,char *,char &,char *,char &> >".
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 1876.6: 1540-0700 (I) The previous message was produced while processing "boost::multiprecision::backends::cpp_dec_float<53,int,void>::rd_string(const char * const)".
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 414.7: 1540-0700 (I) The previous message was produced while processing "boost::multiprecision::backends::cpp_dec_float<53,int,void>::operator=(const char *)".
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 182.16: 1540-0700 (I) The previous message was produced while processing "boost::multiprecision::backends::cpp_dec_float<53,int,void>::cpp_dec_float(const char *)".
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 2605.8: 1540-0700 (I) The previous message was produced while processing "boost::multiprecision::backends::cpp_dec_float<53,int,void>::pow2(const long long)".
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 159.14: 1540-0700 (I) The previous message was produced while processing "boost::multiprecision::backends::cpp_dec_float<53,int,void>::initializer::initializer()".
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 601.72: 1540-0700 (I) The previous message was produced while processing "boost::multiprecision::backends::cpp_dec_float<53,int,void>::init".
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 361.32: 1540-0700 (I) The previous message was produced while processing "boost::multiprecision::backends::cpp_dec_float<53,int,void>::eps()".
"../../../../../../include/boost/multiprecision/cpp_dec_float.hpp", line 52.7: 1540-0700 (I) The previous message was produced while processing "class boost::multiprecision::backends::cpp_dec_float<53,int,void>".
"../../../../../../include/boost/multiprecision/number.hpp", line 38.7: 1540-0700 (I) The previous message was produced while processing "class boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<53,int,void>,0>".
"myTest.cc", line 14.6: 1540-0700 (I) The previous message was produced while processing "averageT(double *)".

'

【问题讨论】:

  • 考虑命名编译器的版本(假设这里是 XlC++)。并在 any 提升包含之前移动定义! (更好的是,将它们移动到您的构建文件中,因为 TU 之间的差异是未来未定义行为的秘诀)
  • C++ 等于受苦,尤其是在 AIX 等外来平台上也许你可以考虑使用 GNU MP Bignum 库

标签: c++ c++11 boost aix


【解决方案1】:

经过更多调查,xlC 似乎无法编译 reverse_iterator。例如,下面的代码在 AIX 上没有被 xlC 编译,原因同上...

#include <string>
#include <iterator>
#include <algorithm>

bool isNonZero(const char c) {
  return c != '0';
}

void test()   {
  std::string str;
  const std::string::const_reverse_iterator rit_non_zero = std::find_if(str.rbegin(), str.rend(), isNonZero);

  if( rit_non_zero != str.rbegin())
    {
      const std::string::size_type ofs = str.length() - std::distance<std::string::const_reverse_iterator>(str.rbegin(), rit_non_zero);
      str.erase(str.begin() + ofs, str.end());
    }
}

【讨论】:

    猜你喜欢
    • 2012-12-21
    • 2014-11-08
    • 2015-12-28
    • 2011-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-10
    • 2012-01-27
    相关资源
    最近更新 更多