[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 <jaylcypher@github.com>
This commit is contained in:
parent
0a8165c0ac
commit
192f7f1b29
2 changed files with 25 additions and 5 deletions
18
src/rcore.c
18
src/rcore.c
|
@ -82,6 +82,19 @@
|
||||||
*
|
*
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Feature Test Macros required for this module
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
#if (defined(__linux__) || defined(PLATFORM_WEB)) && (_XOPEN_SOURCE < 500)
|
||||||
|
#undef _XOPEN_SOURCE
|
||||||
|
#define _XOPEN_SOURCE 500 // Required for: readlink if compiled with c99 without gnu ext.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
#include "raylib.h" // Declares module functions
|
#include "raylib.h" // Declares module functions
|
||||||
|
|
||||||
// Check if config flags have been externally provided on compilation line
|
// Check if config flags have been externally provided on compilation line
|
||||||
|
@ -235,11 +248,6 @@ __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigne
|
||||||
#define FLAG_TOGGLE(n, f) ((n) ^= (f))
|
#define FLAG_TOGGLE(n, f) ((n) ^= (f))
|
||||||
#define FLAG_CHECK(n, f) ((n) & (f))
|
#define FLAG_CHECK(n, f) ((n) & (f))
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Types and Structures Definition
|
// Types and Structures Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
12
src/rglfw.c
12
src/rglfw.c
|
@ -37,6 +37,18 @@
|
||||||
// _GLFW_OSMESA to use the OSMesa API (headless and non-interactive)
|
// _GLFW_OSMESA to use the OSMesa API (headless and non-interactive)
|
||||||
// _GLFW_MIR experimental, not supported at this moment
|
// _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__)
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
#define _GLFW_WIN32
|
#define _GLFW_WIN32
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue