Boost C ++ 1.60中未声明“ gregorian”错误

时间:2018-11-22 16:44:42

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

我的源代码未使用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

1 个答案:

答案 0 :(得分:2)

只需首先包含此标头:

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