https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63400

--- Comment #2 from frankhb1989 at gmail dot com ---
(In reply to Jonathan Wakely from comment #1)
> Which of macros are defined on mingw-w64?
> 
> Preprocessing this should tell you
> 
> #include <chrono>
> #ifdef _GLIBCXX_USE_CLOCK_REALTIME
> #ifdef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL
> #warning system_clock using syscall(SYS_clock_gettime, CLOCK_REALTIME, &tp);
> #else
> #warning system_clock using clock_gettime(CLOCK_REALTIME, &tp);
> #endif
> #elif defined(_GLIBCXX_USE_GETTIMEOFDAY)
> #warning system_clock using gettimeofday(&tv, 0);
> #else
> #warning system_clock using std::time(0);
> #endif
> 
> #ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
> #ifdef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL
> #warning steady_clock using syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &tp);
> #else
> #warning steady_clock using clock_gettime(CLOCK_MONOTONIC, &tp);
> #endif
> #else
> #warning steady_clock using
> time_point(system_clock::now().time_since_epoch());
> #endif

I've looked into c++config.h and I'm sure mingw-w64 4.9.1 distro of msys2 uses
clock_gettime defined in winpthreads:

/* Defined if clock_gettime syscall has monotonic and realtime clock support.
   */
/* #undef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL */

/* Defined if clock_gettime has monotonic clock support. */
#define _GLIBCXX_USE_CLOCK_MONOTONIC 1

/* Defined if clock_gettime has realtime clock support. */
#define _GLIBCXX_USE_CLOCK_REALTIME 1

/* Defined if gettimeofday is available. */
#define _GLIBCXX_USE_GETTIMEOFDAY 1


Here is the output (g++ -std=c++11):

a.cc:7:2: warning: #warning system_clock using clock_gettime(CLOCK_REALTIME,
&tp); [-Wcpp]     
 #warning system_clock using clock_gettime(CLOCK_REALTIME, &tp);                
  ^                                                                             
a.cc:19:2: warning: #warning steady_clock using clock_gettime(CLOCK_MONOTONIC,
&tp); [-Wcpp]   
 #warning steady_clock using clock_gettime(CLOCK_MONOTONIC, &tp);               
  ^

Reply via email to