summaryrefslogtreecommitdiffhomepage
path: root/src/rglfw.c
diff options
context:
space:
mode:
authorJohn <[email protected]>2024-01-20 21:08:19 +0100
committerGitHub <[email protected]>2024-01-20 21:08:19 +0100
commit192f7f1b291d21fbe4bdd2c373e6cf94e69272bb (patch)
tree1a732b4a137059f783eea0cf85aa9cf5e9fc2fc1 /src/rglfw.c
parent0a8165c0acc85bab1624b94ee28ab67535aedbdd (diff)
downloadraylib-192f7f1b291d21fbe4bdd2c373e6cf94e69272bb.tar.gz
raylib-192f7f1b291d21fbe4bdd2c373e6cf94e69272bb.zip
[rcore rglfw] Feature Test Macros before include (#3737)
Move/Add Feature Test Macros before any includes. See: [GNU Feature Test Macros](https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html) > You should define these macros by using ‘#define’ preprocessor directives at the top of your source code files. These directives must come before any #include of a system header file. It is best to make them the very first thing in the file, preceded only by comments. Alternative changes to rcore would be to change _POSIX_C_SOURCE to 200809L, which removes the need to define _XOPEN_SOURCE >= 500. These changes allow for compilation with -std=c* (such as -std=c99) without adding -D macros to the build step. Co-authored-by: JayLCypher <[email protected]>
Diffstat (limited to 'src/rglfw.c')
-rw-r--r--src/rglfw.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/rglfw.c b/src/rglfw.c
index 10ed0954..0e378b5b 100644
--- a/src/rglfw.c
+++ b/src/rglfw.c
@@ -37,6 +37,18 @@
// _GLFW_OSMESA to use the OSMesa API (headless and non-interactive)
// _GLFW_MIR experimental, not supported at this moment
+//----------------------------------------------------------------------------------
+// Feature Test Macros required for this module
+//----------------------------------------------------------------------------------
+#if (defined(__linux__) || defined(PLATFORM_WEB)) && (_POSIX_C_SOURCE < 199309L)
+ #undef _POSIX_C_SOURCE
+ #define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without gnu ext.
+#endif
+#if (defined(__linux__) || defined(PLATFORM_WEB)) && !defined(_GNU_SOURCE)
+ #undef _GNU_SOURCE
+ #define _GNU_SOURCE // Required for: ppoll if compiled with c99 without gnu ext.
+#endif
+
#if defined(_WIN32) || defined(__CYGWIN__)
#define _GLFW_WIN32
#endif