繁体   English   中英

boost头文件中的编译错误。 在Centos 7上失败,在Ubuntu 16.04上编译

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

我遇到了一个奇怪的编译问题。 解决任何帮助将不胜感激。 我将我的应用程序链接到Boost库。 我需要在Centos和Ubuntu上都编译我的应用程序。 在Ubuntu上一切正常,在Centos 7上无法编译相同的代码。错误的位置在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

这会导致编译错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM