From 272073785f17f9b202a5b2a62265bbbd2940b07e Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Sun, 11 Jun 2017 11:20:30 +0200 Subject: [PATCH] Add define to have CLOCK_MONOTONIC work in c99 If we compile with c99 without gnu extensions (gnu99) we need this define, to have CLOCK_MONOTONIC and similar macros available --- src/core.c | 4 ++++ src/gestures.h | 5 +++-- src/physac.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core.c b/src/core.c index 95f704d17..f2ecfa043 100644 --- a/src/core.c +++ b/src/core.c @@ -109,6 +109,10 @@ #include "external/gif.h" // Support GIF recording #endif +#if defined(__linux__) || defined(PLATFORM_WEB) + #define _POSIX_C_SOURCE 199309L // Required for CLOCK_MONOTONIC if compiled with c99 without gnu ext. +#endif + #include // Standard input / output lib #include // Required for: malloc(), free(), rand(), atexit() #include // Required for: typedef unsigned long long int uint64_t, used by hi-res timer diff --git a/src/gestures.h b/src/gestures.h index f04bf091e..f4d38dfb9 100644 --- a/src/gestures.h +++ b/src/gestures.h @@ -148,8 +148,9 @@ float GetGesturePinchAngle(void); // Get gesture pinch ang int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount); int __stdcall QueryPerformanceFrequency(unsigned long long int *lpFrequency); #elif defined(__linux__) - #include // Required for: timespec - #include // Required for: clock_gettime() + #define _POSIX_C_SOURCE 199309L // Required for CLOCK_MONOTONIC if compiled with c99 without gnu ext. + #include // Required for: timespec + #include // Required for: clock_gettime() #endif //---------------------------------------------------------------------------------- diff --git a/src/physac.h b/src/physac.h index d3fdaca46..8c109935d 100644 --- a/src/physac.h +++ b/src/physac.h @@ -253,6 +253,7 @@ PHYSACDEF void ClosePhysics(void); int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount); int __stdcall QueryPerformanceFrequency(unsigned long long int *lpFrequency); #elif defined(__linux__) || defined(PLATFORM_WEB) + #define _POSIX_C_SOURCE 199309L // Required for CLOCK_MONOTONIC if compiled with c99 without gnu ext. //#define _DEFAULT_SOURCE // Enables BSD function definitions and C99 POSIX compliance #include // Required for: timespec #include // Required for: clock_gettime()