簡體   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