c++ - Boost C++ 1.60 中的 `gregorian has not been declared` 错误

标签 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

最佳答案

只需首先包含此 header :

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

关于c++ - Boost C++ 1.60 中的 `gregorian has not been declared` 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53435282/

相关文章:

java - 公历

c++ - 错误 LNK2022 元数据操作失败 (8013118D) : Inconsistent layout information in duplicated types (ChooseDeviceParam): (0x02000273)

c++ - 创建一个boost::thread并将其传递给HANDLE

c++ - ofstream 麻烦,我该如何解决?

c++ - cmake 无法在自定义位置或库存位置找到 boost

c++ - boost asio 和 coroutine2 示例

java - 从各个 "if"s 中创建一个长/大 "if'”

c++ - 如何使用 cout 打印 0x0a 而不是 0xa?

c++ - C++中tstring到string的转换