From d8da7293efcccd1d2f2f49ae518be576399a6f26 Mon Sep 17 00:00:00 2001 From: Hugues Delorme Date: Wed, 14 Dec 2016 15:46:59 +0100 Subject: [PATCH] Drop C90 support for C99 instead --- .travis.yml | 7 ---- CMakeLists.txt | 52 ++++++++++++--------------- README.md | 2 +- appveyor.yml | 7 ++-- src/3rdparty/miloyip_itoa/branchlut.c | 4 +-- travis-build-script.sh | 10 ------ 6 files changed, 27 insertions(+), 55 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8df475d..cccf757 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,9 +19,6 @@ matrix: # Linux GCC-4.6 debug google_double-conversion - compiler: gcc env: TRAVIS_BUILD_TYPE=Debug TRAVIS_FLOAT2STR_LIB=google_doubleconversion - # Linux GCC-4.6 debug no-dll c90 - - compiler: gcc - env: TRAVIS_BUILD_TYPE=Debug TRAVIS_BUILD_DLL=OFF TRAVIS_STRICT_C90=ON # Linux GCC-4.9 release - compiler: gcc-4.9 addons: *gcc49-packages @@ -34,10 +31,6 @@ matrix: - os: osx compiler: clang env: TRAVIS_BUILD_TYPE=Debug TRAVIS_FLOAT2STR_LIB=google_doubleconversion - # OSX Clang debug no-dll c90 - - os: osx - compiler: clang - env: TRAVIS_BUILD_TYPE=Debug TRAVIS_BUILD_DLL=OFF TRAVIS_STRICT_C90=ON # OSX Clang release - os: osx compiler: clang diff --git a/CMakeLists.txt b/CMakeLists.txt index f39d062..24e027b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,7 +68,6 @@ endif() # Options option(GMIO_BUILD_DLL "Build gmio also as a shared library(DLL)" ON) -option(GMIO_BUILD_STRICT_C90 "Build gmio library(and tests) with strict conformance to C90 standard" OFF) option(GMIO_BUILD_BENCHMARKS "Build performance benchmarks for the gmio library" OFF) option(GMIO_BUILD_EXAMPLES "Build gmio examples" OFF) option(GMIO_BUILD_TESTS_FAKE_SUPPORT "Build tests/fake_support target" OFF) @@ -123,19 +122,14 @@ message(STATUS "GMIO_TARGET_ARCH_BIT_SIZE = ${GMIO_TARGET_ARCH_BIT_SIZE}") include(TestBigEndian) test_big_endian(GMIO_HOST_IS_BIG_ENDIAN) -# Adapt C compiler flags to satisfy the GMIO_BUILD_STRICT_C90 option -# It must be done before checking non ANSI features(C99, POSIX, ...) -if(GMIO_BUILD_STRICT_C90) - if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ansi -pedantic-errors") - elseif(MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Za") - endif() +# Adapt C compiler flags to enable strict ISO C99 conformance +if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -pedantic-errors") endif() set(CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS}") -# Some compilers (like GCC v4.9) don't disable in C90 mode +# Some compilers (like GCC v4.9) don't disable when needed check_include_files(stdint.h GMIO_HAVE_STDINT_H) # Find size of short, int and long types @@ -167,29 +161,27 @@ elseif(HAVE_GMIO_SIZEOF_LONG_LONG) set(GMIO_HAVE_LONG_LONG ${HAVE_GMIO_SIZEOF_LONG_LONG}) endif() -# Check C99 features -if(NOT GMIO_BUILD_STRICT_C90) - if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE) - list(APPEND CMAKE_REQUIRED_LIBRARIES m) # -lm - endif() - check_function_exists(powf GMIO_HAVE_POWF_FUNC) - check_function_exists(sqrtf GMIO_HAVE_SQRTF_FUNC) - check_function_exists(strtof GMIO_HAVE_STRTOF_FUNC) - check_symbol_exists(isfinite math.h GMIO_HAVE_ISFINITE_MACRO) - check_symbol_exists(isnan math.h GMIO_HAVE_ISNAN_MACRO) - set(CMAKE_REQUIRED_LIBRARIES) # Pop changes +# Check Available C99 features +if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE) + list(APPEND CMAKE_REQUIRED_LIBRARIES m) # -lm +endif() +check_function_exists(powf GMIO_HAVE_POWF_FUNC) +check_function_exists(sqrtf GMIO_HAVE_SQRTF_FUNC) +check_function_exists(strtof GMIO_HAVE_STRTOF_FUNC) +check_symbol_exists(isfinite math.h GMIO_HAVE_ISFINITE_MACRO) +check_symbol_exists(isnan math.h GMIO_HAVE_ISNAN_MACRO) +set(CMAKE_REQUIRED_LIBRARIES) # Pop changes - check_include_files(stdbool.h GMIO_HAVE_STDBOOL_H) +check_include_files(stdbool.h GMIO_HAVE_STDBOOL_H) - check_function_exists(snprintf GMIO_HAVE_SNPRINTF_FUNC) - if(WIN32 AND NOT GMIO_HAVE_SNPRINTF_FUNC) - check_function_exists(_snprintf GMIO_HAVE_WIN__SNPRINTF_FUNC) - endif() +check_function_exists(snprintf GMIO_HAVE_SNPRINTF_FUNC) +if(WIN32 AND NOT GMIO_HAVE_SNPRINTF_FUNC) + check_function_exists(_snprintf GMIO_HAVE_WIN__SNPRINTF_FUNC) +endif() - check_function_exists(vsnprintf GMIO_HAVE_VSNPRINTF_FUNC) - if(WIN32 AND NOT GMIO_HAVE_VSNPRINTF_FUNC) - check_function_exists(_vsnprintf GMIO_HAVE_WIN__VSNPRINTF_FUNC) - endif() +check_function_exists(vsnprintf GMIO_HAVE_VSNPRINTF_FUNC) +if(WIN32 AND NOT GMIO_HAVE_VSNPRINTF_FUNC) + check_function_exists(_vsnprintf GMIO_HAVE_WIN__VSNPRINTF_FUNC) endif() # Check POSIX features diff --git a/README.md b/README.md index 7082478..927690f 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ gmio is a reusable C library providing complete I/O support for various CAD file formats(eg. [STL](https://en.wikipedia.org/wiki/STL_%28file_format%29)) gmio aims to be [fast](https://github.com/fougue/gmio/wiki/4.-Benchmarks), -portable(C90 conformance) and feature-rich. +portable(C99 conformance) and feature-rich. Main highlights: diff --git a/appveyor.yml b/appveyor.yml index 14df15b..d1a365a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,12 +14,10 @@ clone_folder: c:\projects\gmio.git environment: matrix: - - APPVEYOR_BUILD_DLL: ON - APPVEYOR_CMAKE_GENERATOR: "Visual Studio 12 2013" + - APPVEYOR_CMAKE_GENERATOR: "Visual Studio 12 2013" APPVEYOR_FLOAT2STR_LIB: std - - APPVEYOR_BUILD_DLL: ON - APPVEYOR_CMAKE_GENERATOR: "Visual Studio 12 2013" + - APPVEYOR_CMAKE_GENERATOR: "Visual Studio 12 2013" APPVEYOR_FLOAT2STR_LIB: google_doubleconversion build: @@ -32,7 +30,6 @@ build_script: -G "%APPVEYOR_CMAKE_GENERATOR%" ^ -DCMAKE_BUILD_TYPE=%CONFIGURATION% ^ -DCMAKE_DEBUG_POSTFIX=_d ^ - -DGMIO_BUILD_DLL=%APPVEYOR_BUILD_DLL% ^ -DGMIO_FLOAT2STR_LIB=%APPVEYOR_FLOAT2STR_LIB% ^ -DGMIO_BUILD_EXAMPLES=ON ^ -DGMIO_BUILD_BENCHMARKS=ON ^ diff --git a/src/3rdparty/miloyip_itoa/branchlut.c b/src/3rdparty/miloyip_itoa/branchlut.c index 24a8147..d892ec5 100644 --- a/src/3rdparty/miloyip_itoa/branchlut.c +++ b/src/3rdparty/miloyip_itoa/branchlut.c @@ -3,7 +3,7 @@ * https://github.com/miloyip/itoa-benchmark/src/branchlut.cpp * commit #27c6059 * - * Adapted to be C90 compatible + * Adapted to be C99 compatible */ #include "branchlut.h" @@ -112,7 +112,7 @@ char* i32toa_branchlut(int32_t value, char* buffer) { } #ifdef GMIO_HAVE_INT64_TYPE -/* C90 does not support ULL literals */ +/* In case the compiler does not support ULL literals(C99) */ #define GMIO_UINT64_C(high32, low32) (((uint64_t)(high32) << 32) | (low32)) static const uint64_t one_e16 = GMIO_UINT64_C(0x002386f2, 0x6fc10000); static const uint64_t one_e15 = GMIO_UINT64_C(0x00038d7e, 0xa4c68000); diff --git a/travis-build-script.sh b/travis-build-script.sh index 46aad86..e506a29 100644 --- a/travis-build-script.sh +++ b/travis-build-script.sh @@ -21,14 +21,6 @@ if [ -n "${TRAVIS_GCC_VERSION}" ]; then export CXX=g++-$TRAVIS_GCC_VERSION; fi -if [ -z "${TRAVIS_BUILD_DLL}" ]; then - export TRAVIS_BUILD_DLL=OFF; -fi - -if [ -z "${TRAVIS_STRICT_C90}" ]; then - export TRAVIS_STRICT_C90=OFF; -fi - if [ -z "${TRAVIS_FLOAT2STR_LIB}" ]; then export TRAVIS_FLOAT2STR_LIB=std; fi @@ -41,8 +33,6 @@ cmake .. -G "Unix Makefiles" \ -DCMAKE_DEBUG_POSTFIX=_d \ -DCMAKE_BUILD_TYPE=$TRAVIS_BUILD_TYPE \ -DCMAKE_INSTALL_PREFIX=../install \ - -DGMIO_BUILD_DLL=$TRAVIS_BUILD_DLL \ - -DGMIO_BUILD_STRICT_C90=$TRAVIS_STRICT_C90 \ -DGMIO_BUILD_EXAMPLES=ON \ -DGMIO_BUILD_BENCHMARKS=ON \ -DGMIO_BUILD_BENCHMARK_ASSIMP=OFF \