From 681d5010d53cc2631ad96afa5dfc7ea70f13e5de Mon Sep 17 00:00:00 2001 From: Georg Sauthoff Date: Sat, 27 Aug 2016 10:47:50 +0200 Subject: use gnu c99 to get both c99 and POSIX when compiling with gcc fixes fileno() implicitly defined on Linx and compile error on Solaris 10 --- cmake_unofficial/CMakeLists.txt | 22 ++++++++++++---------- examples/Makefile | 2 +- lib/Makefile | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/cmake_unofficial/CMakeLists.txt b/cmake_unofficial/CMakeLists.txt index 3f113b1..af39cb0 100644 --- a/cmake_unofficial/CMakeLists.txt +++ b/cmake_unofficial/CMakeLists.txt @@ -92,21 +92,23 @@ endif() #warnings if(MSVC) -ADD_DEFINITIONS("-W4") + ADD_DEFINITIONS("-W4") endif() if(GNU_COMPATIBLE_COMPILER) -ADD_DEFINITIONS("-Wall") + ADD_DEFINITIONS("-Wall") endif() if(CMAKE_COMPILER_IS_GNUCXX) -ADD_DEFINITIONS("-Wextra") -ADD_DEFINITIONS("-Wundef") -ADD_DEFINITIONS("-Wshadow") -ADD_DEFINITIONS("-Wcast-align") -ADD_DEFINITIONS("-Wstrict-prototypes") + ADD_DEFINITIONS("-Wextra") + ADD_DEFINITIONS("-Wundef") + ADD_DEFINITIONS("-Wshadow") + ADD_DEFINITIONS("-Wcast-align") + ADD_DEFINITIONS("-Wstrict-prototypes") endif(CMAKE_COMPILER_IS_GNUCXX) -if(GNU_COMPATIBLE_COMPILER AND - (NOT CMAKE_SYSTEM_NAME MATCHES "SunOS")) -ADD_DEFINITIONS("-std=c99") +if(GNU_COMPATIBLE_COMPILER) + # we need gnu99 instead of c99 on Linux and Solaris + # to get C99 and POSIX definitions + # an alternative with cmake >= 3.1/3.2 is the C_STANDARD property + ADD_DEFINITIONS("-std=gnu99") endif() ADD_DEFINITIONS("-DLZ4_VERSION=\"${CPACK_PACKAGE_VERSION_PATCH}\"") INCLUDE_DIRECTORIES (${LZ4_DIR}) diff --git a/examples/Makefile b/examples/Makefile index 1e4f075..c8caf24 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -28,7 +28,7 @@ # ########################################################################## CFLAGS ?= -O3 -CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes +CFLAGS += -std=gnu99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes FLAGS := -I../lib $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) TESTFILE= Makefile diff --git a/lib/Makefile b/lib/Makefile index 879d2b3..52e0f95 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -41,7 +41,7 @@ DESTDIR?= PREFIX ?= /usr/local CPPFLAGS= -DXXH_NAMESPACE=LZ4_ CFLAGS ?= -O3 -CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wcast-qual -Wstrict-prototypes -pedantic +CFLAGS += -std=gnu99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wcast-qual -Wstrict-prototypes -pedantic FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) LIBDIR?= $(PREFIX)/lib -- cgit v0.12