Skip to content

Conversation

@JayLCypher
Copy link
Contributor

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

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.

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.

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.
@raysan5 raysan5 merged commit 192f7f1 into raysan5:master Jan 20, 2024
@raysan5
Copy link
Owner

raysan5 commented Jan 20, 2024

@JayLCypher Thanks for the review, I can't see any potential issue with this change...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants