GNOME Bugzilla – Bug 747692
check build error on osx: pipelines/tcp.c:161:34: error: use of undeclared identifier 'SOCK_CLOEXEC'
Last modified: 2015-04-26 19:16:04 UTC
The fix is to add: #ifndef SOCK_CLOEXEC #define SOCK_CLOEXEC 02000000 #endif
Created attachment 301686 [details] [review] tests: use FD_CLOEXEC when SOCK_CLOEXEC is not available I did not know the problem was already reported so I made another solution based on glib/gio/gsocket.c::g_socket.
Review of attachment 301686 [details] [review]: ::: tests/check/pipelines/tcp.c @@ +36,3 @@ #include <unistd.h> +#ifndef G_OS_WIN32 And here @@ +124,3 @@ } +#ifndef G_OS_WIN32 Shouldn't this be #ifndef SOCK_CLOEXEC for symmetry? @@ +168,3 @@ return FALSE; } +#ifndef G_OS_WIN32 And here?
It seems SOCK_CLOEXEC is not available on G_OS_WIN32. I simplified a bit https://git.gnome.org/browse/glib/tree/gio/gsocket.c#n454 which also handles the case where SOCK_CLOEXEC is defined in libc header but not available in the kernel: "/* It's possible that libc has SOCK_CLOEXEC but the kernel does not */". I skipped this as this is a unit test but I can re-add. Note that I should have put: #if !defined(SOCK_CLOEXEC) && !defined(G_OS_WIN32) instead of just #ifndef G_OS_WIN32 maybe this is your question.
Yes, or some explanation why the #ifdefs are inconsistent :) And what happens if neither of those code blocks is actually used.
My question is: why is SOCK_CLOEXEC needed here at all? Can't it just be removed?
(In reply to Tim-Philipp Müller from comment #5) > My question is: why is SOCK_CLOEXEC needed here at all? Can't it just be > removed? Force of habit I suppose. I don't think it's necessary.
Great, thanks for confirming. Let's keep it simple then: commit 508ae9c2fc2e7ee89c1a9a2c75129c3189a205ed Author: Tim-Philipp Müller <tim@centricular.com> Date: Sun Apr 26 20:13:01 2015 +0100 tests: tcp: remove SOCK_CLOEXEC which causes build problems on OS/X It's not needed here. https://bugzilla.gnome.org/show_bug.cgi?id=747692