Boost date/time microsec_clock not compiling correctly

891 views Asked by At

I'm trying to use the date/time facilities of the C++ Boost library v1.41. (Note: this is Linux, not Windows; g++ v4.4.7)

Code:

#include <boost/date_time/posix_time/posix_time.hpp>
using boost::posix_time::ptime;
using boost::date_time::microsec_clock;
 :
t1 = (boost::date_time::microsec_clock::local_time()); // line 208

The error:

tom.cpp:208: error: 'template<class time_type> class boost::date_time::microsec_clock' used without template parameters

Now, there's this in boost/date_time/posix_time/posix_time_types.hpp:

#ifdef BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK
  //! A time clock that has a resolution of one microsecond
  /*! \ingroup time_basics
   */
  typedef date_time::microsec_clock<ptime> microsec_clock;
#endif

What I'm concluding is that BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK is undefined, resulting in the typedef never happening, resulting in the reference to "microsec_clock" looking like it needed a template parameter.

As far as I can tell, I'm following the Boost date_time documentation to the letter. Any ideas?

1

There are 1 answers

0
Felix Kübler On

I have the same problem right now. Yesterday it worked without any problems but today I needed to delete all my compiled libraries and recompile them due to a svn corruption problem. Ever since this error occurred.

The way to fix it is rather simple. Just use

t1 = (boost::posix_time::microsec_clock::local_time());

instead of

t1 = (boost::date_time::microsec_clock::local_time());

This will preset the time type to posix format however it will not fix the initial problem with BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK.

I hope this was of help to you.