[rcore rglfw] Feature Test Macros before include #3737
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reference to #254
Original issue seems resolved by build step (make, cmake, zig), however looking at the source code, it seems the original intent was to include the Feature Test Macros per file. This seems logical for self-documenting purposes and outline requirements for raylib.
However, the macros are defined after includes, so they won't work.
See: GNU Feature Test Macros
I've simply moved the rcore _POSIX_C_SOURCE feature test macro to the top and included _XOPEN_SOURCE for readlink function.
Alternative change to rcore would be to define_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, for the specially interested.
(any tsoding nobbers in chat?)Additionally, added the macros to rglfw, such that the external includes have their respective functions defined.
I went through the other modules and compiled their object files with both -std=c99 and -std=c2x, and found no other required macros. Also ran the Github Actions for Linux, Windows, Web, Android with no issues.