From 75abeca4a9d606bee89a41475f2f451187fec127 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 4 Feb 2023 18:17:39 -0800 Subject: More compliance with C11. --- timer/include/timer.h | 4 ++++ timer/src/timer.c | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'timer') diff --git a/timer/include/timer.h b/timer/include/timer.h index a8a3f8b..b65f8d4 100644 --- a/timer/include/timer.h +++ b/timer/include/timer.h @@ -6,6 +6,10 @@ #ifdef _WIN32 typedef uint64_t time_point; #else +// Need to macro to make CLOCK_REALTIME available when compiling with ISO C11. +// The constant is only needed in the source file, but the header file needs to +// include time.h too. +#define __USE_POSIX199309 #include typedef struct timespec time_point; #endif diff --git a/timer/src/timer.c b/timer/src/timer.c index 0c33e51..da3485b 100644 --- a/timer/src/timer.c +++ b/timer/src/timer.c @@ -1,16 +1,15 @@ #include "timer.h" #include - #ifdef _WIN32 -static const int64_t microseconds = 1000000; +#define WIN32_LEAN_AND_MEAN +#include #endif -static const int64_t nanoseconds = 1000000000; #ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include +static const int64_t microseconds = 1000000; #endif +static const int64_t nanoseconds = 1000000000; #ifdef _WIN32 static double seconds_per_count; -- cgit v1.2.3