From 771618e6c29c793a1b561dab77741dc00bf99778 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen Date: Thu, 18 Dec 2014 23:41:48 +0100 Subject: [PATCH] Fix for compiling with clang -std=c11 on Linux. --- CMakeLists.txt | 3 +++ lib/lws-plat-unix.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43630f7e2..7294a1de7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -393,6 +393,9 @@ if (UNIX) list(APPEND HDR_PRIVATE lib/getifaddrs.h) list(APPEND SOURCES lib/getifaddrs.c) endif() + if (NOT APPLE) + add_definitions(-D_POSIX_SOURCE=1) + endif() endif() if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) diff --git a/lib/lws-plat-unix.c b/lib/lws-plat-unix.c index a7f96a36e..5283c077e 100644 --- a/lib/lws-plat-unix.c +++ b/lib/lws-plat-unix.c @@ -235,7 +235,7 @@ lws_plat_set_socket_options(struct libwebsocket_context *context, int fd) optval = 1; #if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \ !defined(__OpenBSD__) - if (setsockopt(fd, SOL_TCP, TCP_NODELAY, (const void *)&optval, optlen) < 0) + if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const void *)&optval, optlen) < 0) return 1; #else tcp_proto = getprotobyname("TCP");