go-gl/glfw

v3.3/glfw: _GNU_SOURCE is defined twice, emits a warning

Jacalz opened this issue · 4 comments

As of upstream glfw v3.3.7 (and #350), it is now setting _GNU_SOURCE along with our v3.3/glfw/build.go setting it for us. This means that the C-compiler files a warning about it being defined twice.

# github.com/go-gl/glfw/v3.3/glfw
In file included from ../glfw/v3.3/glfw/c_glfw_lin.go:20:
../glfw/v3.3/glfw/glfw/src/x11_window.c:30: warning: "_GNU_SOURCE" redefined
   30 | #define _GNU_SOURCE
      | 
<command-line>: note: this is the location of the previous definition

The easy fix is to remove -D_GNU_SOURCE from the build.go file but that unfortunatelly makes a another warning pop up.

# github.com/go-gl/glfw/v3.3/glfw
In file included from ../glfw/v3.3/glfw/c_glfw_lin.go:20:
../glfw/v3.3/glfw/glfw/src/x11_window.c: In function ‘waitForData’:
../glfw/v3.3/glfw/glfw/src/x11_window.c:77:32: warning: implicit declaration of function ‘ppoll’; did you mean ‘poll’? [-Wimplicit-function-declaration]
   77 |             const int result = ppoll(fds, count, &ts, NULL);
      |                                ^~~~~
      |                                poll

We need to find a better way of solving this.

I am thinking about this once more. Isn't this actually an upstream issue now? I know that it wasn't before as we were the ones setting _GNU_SOURCE, but now that we are not, the upstream src/x11_window.c file seems to not have the variable set.

Yeah, if we stop defining _GNU_SOURCE and that causes a warning in GLFW C codebase due to _GNU_SOURCE not being defined, that might be something that is better suited to be addressed upstream.

Are we able to reproduce this problem when building the upstream GLFW C 3.3.7 codebase from source? If not, why not? (I don't have ready access to Linux to investigate this right now, so I'll give others a chance to get to this first.)

I am afraid that I don't have enough C-knowlage to get the upstream code built. The build systems are a mess.
However, I can easy say that something is very strange given that the file in question does https://github.com/glfw/glfw/blob/b43c122dd194d74996d76c574a46d4bc23d6c7b0/src/x11_window.c#L30 indeed define _GNU_SOURCE.

Getting the same warning, any way we can fix this?