Boost logo

Boost :

Subject: Re: [boost] [chrono] chrono/config.hpp enforces that time.h defines CLOCK_REALTIME; should it?
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2012-06-27 14:03:35


Le 27/06/12 14:31, Krzysztof Czainski a écrit :
> Hello,
>
> Suppose I want to use durations, and time_points with a user defined clock.
> I don't want to use any clocks provided by Boost.Chrono.
>
> My compiler provides a<time.h>, which doesn't define CLOCK_REALTIME, which
> chrono/config.hpp reports as an error. This prevents me from using parts of
> Chrono, that I believe don't depend on anything from<time.h>.
chrono/config.hpp contains

# if defined( BOOST_CHRONO_POSIX_API )
# define BOOST_CHRONO_HAS_PROCESS_CLOCKS
# include <time.h> //to check for CLOCK_REALTIME and CLOCK_MONOTONIC
and _POSIX_THREAD_CPUTIME
# if defined(CLOCK_REALTIME)
# if defined(CLOCK_MONOTONIC)
# define BOOST_CHRONO_HAS_CLOCK_STEADY
# endif
# else
# error <time.h> does not supply CLOCK_REALTIME
# endif
...
# endif

if CLOCK_REALTIME is not defined this means that we are unable to
provide system_clock which is mandatory. This is why there is an error.
Maybe this could only be included only when including system_clocks.hpp.
Please could you make a feature request on the Trac system?
>
> I am able to work around this by simply defining CLOCK_REALTIME. But I
> would like to ask: Could Boost.Chrono allow using duration.hpp and
> time_point.hpp in my case?
I think so, but you will need to try it.

Best,
Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk