Opened 10 years ago
Closed 10 years ago
#7042 closed Feature Requests (fixed)
Avoiding time_point and duration dependency on time.h and CLOCK_REALTIME
Reported by: | Owned by: | viboes | |
---|---|---|---|
Milestone: | Boost 1.51.0 | Component: | chrono |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | Cc: |
Description
Hello,
The file chrono/config.hpp enforces that time.h defines CLOCK_REALTIME:
# 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
It seems that files: chrono/duration.hpp and chrono/time_point.hpp don't need to depend on <time.h> or CLOCK_REALTIME. If a compiler provides a <time.h>, which doesn't define CLOCK_REALTIME, or even doesn't provide <time.h>, it would be nice to still be able to use chrono/duration.hpp or chrono/time_point.hpp.
Regards, Kris
Attachments (2)
Change History (7)
comment:1 by , 10 years ago
by , 10 years ago
Attachment: | 7042.patch added |
---|
comment:2 by , 10 years ago
Please, could you tell me if the attached patch 7042.2.patch solves the issue with CLOCK_REALTIME?
by , 10 years ago
Attachment: | 7042.2.patch added |
---|
comment:3 by , 10 years ago
Yes, I confirm, patch 7042.2.patch solves the issue with CLOCK_REALTIME.
Cheers, Kris
comment:4 by , 10 years ago
Milestone: | To Be Determined → Boost 1.51.0 |
---|---|
Status: | new → assigned |
As a workaround, I was able to use time_point.hpp and duration.hpp by defining CLOCK_REALTIME in my project. Of course, I am not using any clocks provided by Chrono.