Modify

Ticket #7042 (closed Feature Requests: fixed)

Opened 22 months ago

Last modified 22 months ago

Avoiding time_point and duration dependency on time.h and CLOCK_REALTIME

Reported by: 1czajnik@… 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

7042.patch Download (1.4 KB) - added by viboes 22 months ago.
7042.2.patch Download (1.6 KB) - added by viboes 22 months ago.

Change History

comment:1 Changed 22 months ago by 1czajnik@…

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.

Changed 22 months ago by viboes

comment:2 Changed 22 months ago by viboes

Please, could you tell me if the attached patch 7042.2.patch solves the issue with CLOCK_REALTIME?

Last edited 22 months ago by viboes (previous) (diff)

Changed 22 months ago by viboes

comment:3 Changed 22 months ago by 1czajnik@…

Yes, I confirm, patch 7042.2.patch solves the issue with CLOCK_REALTIME.

Cheers, Kris

comment:4 Changed 22 months ago by viboes

  • Status changed from new to assigned
  • Milestone changed from To Be Determined to Boost 1.51.0

comment:5 Changed 22 months ago by viboes

  • Status changed from assigned to closed
  • Resolution set to fixed

Committed revision 79371.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.