Skip to content

Commit

Permalink
CMake: Don't compile with -D_GNU_SOURCE
Browse files Browse the repository at this point in the history
We do not want to compile with GNU-specific extensions, as we want the
code to be as portable as possible.

Thanksfully we don't actually need _GNU_SOURCE to be defined, removing
it only triggers an error in network-unix.c about an undefined
structure, which we can fix by including the right header.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
  • Loading branch information
pcercuei committed May 11, 2021
1 parent bc4385e commit a494f0c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ endif()
if(APPLE)
#full Single Unix Standard v3 (SUSv3) conformance (the Unix API)
add_definitions(-D_DARWIN_C_SOURCE)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE=1")
add_definitions(-D_GNU_SOURCE=1)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD|DragonFly|OpenBSD|NetBSD")
set(CMAKE_REQUIRED_DEFINITIONS "-D__BSD_VISIBLE")
add_definitions(-D__BSD_VISIBLE=1)
Expand Down
1 change: 1 addition & 0 deletions network-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <poll.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <unistd.h>

int set_blocking_mode(int fd, bool blocking)
Expand Down

0 comments on commit a494f0c

Please sign in to comment.