在Boost标头文件中编译错误.Centos 7失败,在Ubuntu上编译16.04

Compile error in boost header file. Fails on Centos 7, compiles on Ubuntu 16.04

本文关键字:编译 失败 Ubuntu 错误 Boost 文件 Centos      更新时间:2023-10-16

我正在遇到一个奇怪的汇编问题。在解决方面的任何帮助都将不胜感激。我将应用程序链接到Boost库。我需要在CentOS和Ubuntu上编译我的应用程序。一切都在Ubuntu上正常工作,并且相同的代码无法在CentOS 7上编译。错误的位置在Boost中。不确定该问题是否实际上是在提升中,还是其他原因导致错误显示在Boost中。搜索错误时,我遇到了此链接。但是,这个问题是针对较旧版本的Boost。我列出了下面的错误输出:

        /usr/local/include/boost/chrono/duration.hpp: In function 'constexpr typename boost::enable_if<boost::mpl::and_<boost::is_convertible<Rep1, typename boost::common_type<Rep1, Rep2>::type>, boost::is_convertible<Rep2, typename boost::common_type<Rep1, Rep2>::type> >, boost::chrono::duration<typename boost::common_type<Rep1, Rep2>::type, Period> >::type boost::chrono::operator*(const boost::chrono::duration<Rep, Period>&, const Rep2&)':
In file included from /usr/local/include/boost/chrono/time_point.hpp:33:0,
                 from /usr/local/include/boost/thread/lock_types.hpp:22,
                 from /usr/local/include/boost/thread/lock_algorithms.hpp:11,
                 from /usr/local/include/boost/thread/locks.hpp:10,
    ...
    /usr/local/include/boost/chrono/duration.hpp:575:34: error: type/value mismatch at argument 1 in template parameter list for 'template<class Rep, class Period> class boost::chrono::duration'
           typedef duration<CR, Period> CD;
                                      ^
    /usr/local/include/boost/chrono/duration.hpp:575:34: error:   expected a type, got '13u'
    /usr/local/include/boost/chrono/duration.hpp:575:38: error: invalid type in declaration before ';' token
           typedef duration<CR, Period> CD;

来自/usr/local/include/boost/chrono/duration.hpp的相应代码:

    // Duration *
template <class Rep1, class Period, class Rep2>
inline BOOST_CONSTEXPR
typename boost::enable_if <
    mpl::and_ <
    boost::is_convertible<Rep1, typename common_type<Rep1, Rep2>::type>,
    boost::is_convertible<Rep2, typename common_type<Rep1, Rep2>::type>
    >,
    duration<typename common_type<Rep1, Rep2>::type, Period>
>::type
operator*(const duration<Rep1, Period>& d, const Rep2& s)
{
  typedef typename common_type<Rep1, Rep2>::type CR;
  typedef duration<CR, Period> CD;
  return CD(CD(d).count()*static_cast<CR>(s));
}

我在CentOS7上遇到此错误。在Ubuntu上没有发生。

Centos版本:

Boost:1.58.0,OS:CentOS 7,C :G 4.8.5

ubuntu版本:

Boost:1.58.0,OS:Ubuntu 16.04,C :G 5.4.0

不确定C 编译器差异是否是问题。CentOS7上的C 编译器的默认版本为4.8.5。顺便说一句,CentOS7上的默认增强版本为1.53.2。我编译并安装了Boost 1.58.0版本,以最大程度地减少变量。任何帮助是极大的赞赏。谢谢。

我的猜测(仅此而已(,基于错误消息,是您拥有的某个地方:

#define CR 13u

这是导致汇编错误。