【问题标题】:`gregorian has not been declared` error in Boost C++ 1.60Boost C++ 1.60 中的“gregorian has not been declared”错误
【发布时间】:2019-04-25 09:25:46
【问题描述】:

我的源代码没有用Boost C++ 1.60编译

$ g++ -c DateTimeUtil.cpp -I../../../boost_1.60.0/include/

In file included from ../../../boost_1.60.0/include/boost/date_time/local_time_adjustor.hpp:20:0,
                 from BoostDateTime.inl:6,
                 from DateTimeUtil.h:9,
                 from DateTimeUtil.cpp:1:
../../../boost_1.60.0/include/boost/date_time/dst_rules.hpp: In static member function ‘static boost::date_time::us_dst_rules<date_type_, time_duration_type_, dst_start_offset_minutes, dst_length_minutes>::date_type boost::date_time::us_dst_rules<date_type_, time_duration_type_, dst_start_offset_minutes, dst_length_minutes>::local_dst_start_day(boost::date_time::us_dst_rules<date_type_, time_duration_type_, dst_start_offset_minutes, dst_length_minutes>::year_type)’:
../../../boost_1.60.0/include/boost/date_time/dst_rules.hpp:317:45: error: ‘gregorian’ has not been declared
           nkday ssim(nkday::second, Sunday, gregorian::Mar);
                                             ^
../../../boost_1.60.0/include/boost/date_time/dst_rules.hpp:321:30: error: ‘gregorian’ has not been declared
           fkday fsia(Sunday, gregorian::Apr);
                              ^
../../../boost_1.60.0/include/boost/date_time/dst_rules.hpp: In static member function ‘static boost::date_time::us_dst_rules<date_type_, time_duration_type_, dst_start_offset_minutes, dst_length_minutes>::date_type boost::date_time::us_dst_rules<date_type_, time_duration_type_, dst_start_offset_minutes, dst_length_minutes>::local_dst_end_day(boost::date_time::us_dst_rules<date_type_, time_duration_type_, dst_start_offset_minutes, dst_length_minutes>::year_type)’:
../../../boost_1.60.0/include/boost/date_time/dst_rules.hpp:330:30: error: ‘gregorian’ has not been declared
           fkday fsin(Sunday, gregorian::Nov);
                              ^
../../../boost_1.60.0/include/boost/date_time/dst_rules.hpp:334:30: error: ‘gregorian’ has not been declared
           lkday lsio(Sunday, gregorian::Oct);
                              ^

这是我的源代码中包含的内容:

#include <boost/date_time/c_local_time_adjustor.hpp>
#include <boost/date_time/local_time_adjustor.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

系统信息:

$ uname -a
Linux duong2179-ubuntu 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:07:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

$ g++ --version
g++ (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4

【问题讨论】:

    标签: c++ boost gregorian-calendar boost-date-time


    【解决方案1】:

    只需先包含此标题:

    #include <boost/date_time/gregorian/gregorian_types.hpp>
    

    【讨论】:

    • 为什么这个标头没有预先包含在dst_rules.hpp 或其他地方?
    • @duong_dajgja 这个问题和类似的问题,我每天都在处理 boost
    猜你喜欢
    • 2011-10-05
    • 2016-11-18
    • 1970-01-01
    • 2018-09-21
    • 2020-05-23
    • 2019-07-23
    • 2013-05-04
    • 2012-10-04
    相关资源
    最近更新 更多