Boost错误,无法编译xtime.hpp 我一直在使用Boost进行C++项目的工作,在编译程序之间,我必须升级Boost中没有什么含义的东西,因为现在的Boost依赖性不会编译: In file included from /usr/include/boost/thread/pthread/mutex.hpp:14:0, from /usr/include/boost/thread/mutex.hpp:16, from /usr/include/boost/thread/pthread/thread_data.hpp:12, from /usr/include/boost/thread/thread.hpp:17, from /usr/include/boost/thread.hpp:13, from /blah.h:4, from bluh.h:3, from bleh/main.cpp:4: /usr/include/boost/thread/xtime.hpp:23:5: error: expected identifier before numeric constant /usr/include/boost/thread/xtime.hpp:23:5: error: expected '}' before numeric constant /usr/include/boost/thread/xtime.hpp:23:5: error: expected unqualified-id before numeric constant /usr/include/boost/thread/xtime.hpp:46:14: error: expected type-specifier before 'system_time' In file included from /usr/include/boost/thread/pthread/mutex.hpp:14:0, from /usr/include/boost/thread/mutex.hpp:16, from /usr/include/boost/thread/pthread/thread_data.hpp:12, from /usr/include/boost/thread/thread.hpp:17, from /usr/include/boost/thread.hpp:13, from /blah, from /bleh,(changed these names, obviously) from /bluh /main.cpp:4: /usr/include/boost/thread/xtime.hpp: In function 'int xtime_get(xtime*, int)': /usr/include/boost/thread/xtime.hpp:73:40: error: 'get_system_time' was not declared in this scope /usr/include/boost/thread/xtime.hpp:73:40: note: suggested alternative: /usr/include/boost/thread/thread_time.hpp:19:24: note: 'boost::get_system_time' /usr/include/boost/thread/xtime.hpp: At global scope: /usr/include/boost/thread/xtime.hpp:88:1: error: expected declaration before '}' token make[2]: *** [CMakeFiles/edge_based_tracker.dir/main.o] Error 1 make[1]: *** [CMakeFiles/edge_based_tracker.dir/all] Error 2 make: *** [all] Error 2

Boost错误,无法编译xtime.hpp 我一直在使用Boost进行C++项目的工作,在编译程序之间,我必须升级Boost中没有什么含义的东西,因为现在的Boost依赖性不会编译: In file included from /usr/include/boost/thread/pthread/mutex.hpp:14:0, from /usr/include/boost/thread/mutex.hpp:16, from /usr/include/boost/thread/pthread/thread_data.hpp:12, from /usr/include/boost/thread/thread.hpp:17, from /usr/include/boost/thread.hpp:13, from /blah.h:4, from bluh.h:3, from bleh/main.cpp:4: /usr/include/boost/thread/xtime.hpp:23:5: error: expected identifier before numeric constant /usr/include/boost/thread/xtime.hpp:23:5: error: expected '}' before numeric constant /usr/include/boost/thread/xtime.hpp:23:5: error: expected unqualified-id before numeric constant /usr/include/boost/thread/xtime.hpp:46:14: error: expected type-specifier before 'system_time' In file included from /usr/include/boost/thread/pthread/mutex.hpp:14:0, from /usr/include/boost/thread/mutex.hpp:16, from /usr/include/boost/thread/pthread/thread_data.hpp:12, from /usr/include/boost/thread/thread.hpp:17, from /usr/include/boost/thread.hpp:13, from /blah, from /bleh,(changed these names, obviously) from /bluh /main.cpp:4: /usr/include/boost/thread/xtime.hpp: In function 'int xtime_get(xtime*, int)': /usr/include/boost/thread/xtime.hpp:73:40: error: 'get_system_time' was not declared in this scope /usr/include/boost/thread/xtime.hpp:73:40: note: suggested alternative: /usr/include/boost/thread/thread_time.hpp:19:24: note: 'boost::get_system_time' /usr/include/boost/thread/xtime.hpp: At global scope: /usr/include/boost/thread/xtime.hpp:88:1: error: expected declaration before '}' token make[2]: *** [CMakeFiles/edge_based_tracker.dir/main.o] Error 1 make[1]: *** [CMakeFiles/edge_based_tracker.dir/all] Error 2 make: *** [all] Error 2,boost,compilation,makefile,Boost,Compilation,Makefile,有什么想法吗?我试着将TIME_UTC改为TIME_UTC,因为这是在另一个网站上向我推荐的,但似乎没有帮助 编辑:Boost版本为1.48.0.2。我在下面附上了xtime: // Copyright (C) 2001-2003 // William E. Kempf // Copyright (C) 2007-8 Anthony Williams // // Distributed under the Boost Software License, Version 1.0. (See ac

有什么想法吗?我试着将TIME_UTC改为TIME_UTC,因为这是在另一个网站上向我推荐的,但似乎没有帮助

编辑:Boost版本为1.48.0.2。我在下面附上了xtime:

// Copyright (C) 2001-2003
// William E. Kempf
// Copyright (C) 2007-8 Anthony Williams
//
//  Distributed under the Boost Software License, Version 1.0. (See accompanying 
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_XTIME_WEK070601_HPP
#define BOOST_XTIME_WEK070601_HPP

#include <boost/thread/detail/config.hpp>

#include <boost/cstdint.hpp>
#include <boost/thread/thread_time.hpp>
#include <boost/date_time/posix_time/conversion.hpp>

#include <boost/config/abi_prefix.hpp>

namespace boost {

enum xtime_clock_types
{
    TIME_UTC=1 //LINE 23
//    TIME_TAI,
//    TIME_MONOTONIC,
//    TIME_PROCESS,
//    TIME_THREAD,
//    TIME_LOCAL,
//    TIME_SYNC,
//    TIME_RESOLUTION
};

struct xtime
{
#if defined(BOOST_NO_INT64_T)
    typedef int_fast32_t xtime_sec_t; //INT_FAST32_MIN <= sec <= INT_FAST32_MAX
#else
    typedef int_fast64_t xtime_sec_t; //INT_FAST64_MIN <= sec <= INT_FAST64_MAX
#endif

    typedef int_fast32_t xtime_nsec_t; //0 <= xtime.nsec < NANOSECONDS_PER_SECOND

    xtime_sec_t sec;
    xtime_nsec_t nsec;

    operator system_time() const
    {
        return boost::posix_time::from_time_t(0)+
            boost::posix_time::seconds(static_cast<long>(sec))+
#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
            boost::posix_time::nanoseconds(nsec);
#else
        boost::posix_time::microseconds((nsec+500)/1000);
#endif
    }

};

inline xtime get_xtime(boost::system_time const& abs_time)
{
    xtime res;
    boost::posix_time::time_duration const time_since_epoch=abs_time-boost::posix_time::from_time_t(0);

    res.sec=static_cast<xtime::xtime_sec_t>(time_since_epoch.total_seconds());
    res.nsec=static_cast<xtime::xtime_nsec_t>(time_since_epoch.fractional_seconds()*(1000000000/time_since_epoch.ticks_per_second()));
    return res;
}

inline int xtime_get(struct xtime* xtp, int clock_type)
{
    if (clock_type == TIME_UTC)
    {
        *xtp=get_xtime(get_system_time());
        return clock_type;
    }
    return 0;
}


inline int xtime_cmp(const xtime& xt1, const xtime& xt2)
{
    if (xt1.sec == xt2.sec)
        return (int)(xt1.nsec - xt2.nsec);
    else 
        return (xt1.sec > xt2.sec) ? 1 : -1;
}

} // namespace boost

#include <boost/config/abi_suffix.hpp>

#endif //BOOST_XTIME_WEK070601_HPP
//版权所有(C)2001-2003
//威廉·E·肯普夫
//版权所有(C)2007-8安东尼·威廉姆斯
//
//根据Boost软件许可证1.0版发布。(见附页)
//文件LICENSE_1_0.txt或复制到http://www.boost.org/LICENSE_1_0.txt)
#ifndef增压式水电站
#定义增压\u XTIME\u WEK070601\u水电站
#包括
#包括
#包括
#包括
#包括
名称空间提升{
枚举xtime_时钟_类型
{
时间UTC=1//第23行
//泰晤士报,
//时间是单调的,
//时间进程,
//时间线,
//当地时间,
//时间同步,
//时间分辨率
};
结构xtime
{
#如果已定义(BOOST\u NO\u INT64\T)

typedef int\u fast32\u t xtime\u sec\t;//int\u fast32\u MIN由于您没有显示代码,我们只能猜测。我的猜测是您在代码中的某个地方定义了
TIME\u UTC
宏。此宏会弄乱
xtime.hpp
头。

如果使用Boost时出现语法错误,您可能需要使用
-std=c++11编译代码

您可能已经读到的
TIME\u UTC
问题是使用c++11的一个副作用。
TIME\u UTC
现在在c++11中被定义为一个宏,因此您需要将
TIME\u UTC
的所有实例替换为
TIME\u UTC
,或者只使用更新的(1.50.0+)版本的Boost,因为它已经被修复


请参阅:

了解那些遇到相同问题并在此处努力找到解决方案的人。 派生自noodlebox的链接():

您可以编辑/usr/include/boost/thread/xtime.hpp(或您的xtime.hpp所在的任何位置) 并将所有出现的时间协调世界时更改为时间协调世界时——可能在第23行和第71行附近


i、 e.
sed-i's/TIME\UTC/TIME\UTC\ug'/usr/include/boost/thread/xtime.hpp

如果您说出boost的哪个版本,并显示失败的代码,并显示xtime.hpp第23行的内容,并将您的代码简化为一个最小的示例,这将是非常有帮助的。事实上,这个问题目前无法回答。我已经编辑了q添加Boost版本和xtime.hpp。失败的代码只是一个导入语句。您不必复制和粘贴Boost代码。显示您试图编译的代码。第23行是需要的,因此我提出了Boost代码,以便Jonathan Wakely可以看到。正如我在前面的评论中所说,失败的代码是import语句,特别是boost/thread@user650261预处理整个翻译单元,并在预处理的代码中找到这一行。将TIME_UTC替换为TIME_UTC_uu,如@noodlebox建议的-i's/TIME_UTC/TIME_uutc/TIME_uutc/g'/usr/include/boost/thread/xtime.hppHad编译带有boost 1.49.0的PCL 1.7.1库时出现此错误。解决了此问题(但让我想到了另一个错误——噢,天啊!)。我相信您还需要更改libs/thread/src/pthread/timeconv.inl,因为它还包含boost::TIME_UTCSmall注意:它是C11(由lib C的TIME.h完成),而不是C++11(不限于C++)