-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rglfw] fix: suppress warning: "_GNU_SOURCE" redefined #4720
[rglfw] fix: suppress warning: "_GNU_SOURCE" redefined #4720
Conversation
When compiling rglfw.c with GCC or Clang following warning appears: In file included from rglfw.c:99: external/glfw/src/posix_poll.c:27:9: warning: "_GNU_SOURCE" redefined 27 | #define _GNU_SOURCE | ^~~~~~~~~~~ This commit suppresses said warning by checking, if _GNU_SOURCE has NOT been defined, and only then defining it. Since said macro has been always defined in posix_poll and wl_window, this commit does not change any behavior at all (it just suppresses the warning, that's it).
@sleeptightAnsiC I'm afraid this issue belongs to an external library and should be addressed in GLFW repo instead of raylib to avoid being rewritten when updating to next GLFW version. |
Hi @raysan5 , This issue does not belong to GLFW upstream because Raylib is the one causing it. Some of our build systems define Perhaps, this can be fixed in our build systems? I've noticed only two affected: src/Makefile and build.zig. For comparison, Cmake does not define it and works just fine. So maybe Hope you're doing well. |
@sleeptightAnsiC Still, the change applies to GLFW and it will be overriden on update. Afair, @Peter0x44 added? that flag on the past for some specific use-case, maybe he can provide more details and if it is still required. Personally, I'm fine removing it completely from raylib building. |
I can't remember why I needed it, I think it was for accessing clock functions from C99. The warning is preferable to patching glfw, imo, I hope there's a better solution. |
It's a bit strange that Makefile and zig builds can trigger this but Cmake does not. Is Cmake just not defining it or suppressing with something like It would be nice if all build systems were consistent here, either all defining Anyway, I agree this PR was wrong. I'll see later if maybe resolving this in GLFW is possible, since it's still a bit strange that posix_poll.c defines said macro but then uses several build branches for accessing correct variant of poll. |
@sleeptightAnsiC I think I investigated this before, it's because cmake uses And suppressing the warning on the command line is not a good idea imo. |
No no, I'm not saying it should be suppressed, just was wondering if it was.
Well, Makefile and build.zig are also using gnu99, but they redefine _GNU_SOURCE unlike Cmake. |
Line 334 in 49d37b0
The makefile only uses it for web and rgfw web So that's not exactly true. I did not check build.zig. |
Ahh, I see, sorry. zig seems to be using Lines 81 to 88 in 49d37b0
|
I think this requires a bit more research to figure how to properly solve and also isn't particularly urgent. I can also do it if needed. (And slight apology for my comments on our last interaction, figured it was worth a mention) |
sure, I'll open it in a moment
No worries. I tried push my point of view really hard. For this I also apologize. |
When compiling rglfw.c with recent versions of GCC or Clang following warning appears:
This PR suppresses said warning by checking, if _GNU_SOURCE has NOT been defined, and only then defining it. It does not change any behavior, just suppresses the warning.
Raylib already handles similar cases elsewhere in it's source tree (e.g. in rcore.c) so this is nothing new.