简体   繁体   English

使用boost :: posix_time时的编译错误

[英]Compilation error when using boost::posix_time

I am getting the following compilation error when I include boost/date_time/posix_time/posix_time.hpp in my c++ code 当我的C ++代码中包含boost / date_time / posix_time / posix_time.hpp时,出现以下编译错误

/usr/include/boost/date_time/date_facet.hpp:560: error: declaration of ‘void boost::date_time::date_input_facet <date_type, CharT, InItrT>::special_values_parser(boost::date_time::special_values_parser <date_type, charT>)’
/usr/include/boost/date_time/special_values_parser.hpp:34: error: changes meaning of ‘special_values_parser’ from ‘class boost::date_time::special_values_parser <date_type, charT>’

I think that it's just the call to include which is causing the problem . 我认为这只是导致问题的包含项。 I have the following code 我有以下代码

#include "boost/date_time/posix_time/posix_time.hpp" 

class Chrono {
    public: Chrono() : _startTime(boost::posix_time::microsec_clock::local_time()) { ; }
    void reset() { _startTime = boost::posix_time::microsec_clock::local_time() ; }     
    boost::posix_time::time_duration elapsed() const { 
      return (boost::posix_time::microsec_clock::local_time() - _startTime) ; 
    } 
    boost::posix_time::ptime _startTime ; 
};

I use gcc-4.3.4 and boost x86_64 0:1.39.0-9.el5 library 我使用gcc-4.3.4和boost x86_64 0:1.39.0-9.el5库

Does anyone has an idea on this ? 有人对此有想法吗?

Thanks in advance 提前致谢

Regarding your first question: Have you tried with a more recent compiler? 关于第一个问题:您是否尝试过使用较新的编译器? gcc-4.3.4 is positively ancient... I tried with gcc-4.4.6 and boost-1.46 and this combination works fine. gcc-4.3.4确实很古老。我尝试使用gcc-4.4.6和boost-1.46,这种组合效果很好。 Also, the error message you posted is not complete, it looks like at least half of it is missing. 此外,您发布的错误消息还不完整,看起来至少丢失了一半。

As to the second question (the one about your CMakeLists.txt not working): Did you try with a clean binary tree? 关于第二个问题(关于您的CMakeLists.txt的问题不起作用):您是否尝试过使用干净的二叉树? If the cached version (Boost_<XXX>_LIBRARY entries in the CMakeCache.txt file) does not match the version in your CMakeLists.txt file, you will get this kind of error message. 如果缓存的版本(CMakeCache.txt文件中的Boost_ <XXX> _LIBRARY条目)与您的CMakeLists.txt文件中的版本不匹配,您将收到这种错误消息。 This can happen if you ran CMake, it found the old version, and then you added the VERSION requirement. 如果您运行CMake,找到旧版本,然后添加了VERSION要求,则可能发生这种情况。 In that case, the cached entries won't be purged, and you end up with a mess. 在这种情况下,缓存的条目将不会被清除,最终您将一团糟。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM