Drop C90 support for C99 instead

This commit is contained in:
Hugues Delorme 2016-12-14 15:46:59 +01:00
parent f369553af9
commit d8da7293ef
6 changed files with 27 additions and 55 deletions

View File

@ -19,9 +19,6 @@ matrix:
# Linux GCC-4.6 debug google_double-conversion # Linux GCC-4.6 debug google_double-conversion
- compiler: gcc - compiler: gcc
env: TRAVIS_BUILD_TYPE=Debug TRAVIS_FLOAT2STR_LIB=google_doubleconversion 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 # Linux GCC-4.9 release
- compiler: gcc-4.9 - compiler: gcc-4.9
addons: *gcc49-packages addons: *gcc49-packages
@ -34,10 +31,6 @@ matrix:
- os: osx - os: osx
compiler: clang compiler: clang
env: TRAVIS_BUILD_TYPE=Debug TRAVIS_FLOAT2STR_LIB=google_doubleconversion 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 # OSX Clang release
- os: osx - os: osx
compiler: clang compiler: clang

View File

@ -68,7 +68,6 @@ endif()
# Options # Options
option(GMIO_BUILD_DLL "Build gmio also as a shared library(DLL)" ON) 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_BENCHMARKS "Build performance benchmarks for the gmio library" OFF)
option(GMIO_BUILD_EXAMPLES "Build gmio examples" OFF) option(GMIO_BUILD_EXAMPLES "Build gmio examples" OFF)
option(GMIO_BUILD_TESTS_FAKE_SUPPORT "Build tests/fake_support target" 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) include(TestBigEndian)
test_big_endian(GMIO_HOST_IS_BIG_ENDIAN) test_big_endian(GMIO_HOST_IS_BIG_ENDIAN)
# Adapt C compiler flags to satisfy the GMIO_BUILD_STRICT_C90 option # Adapt C compiler flags to enable strict ISO C99 conformance
# It must be done before checking non ANSI features(C99, POSIX, ...) if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE)
if(GMIO_BUILD_STRICT_C90) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -pedantic-errors")
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()
endif() endif()
set(CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS}") set(CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS}")
# Some compilers (like GCC v4.9) don't disable <stdint.h> in C90 mode # Some compilers (like GCC v4.9) don't disable <stdint.h> when needed
check_include_files(stdint.h GMIO_HAVE_STDINT_H) check_include_files(stdint.h GMIO_HAVE_STDINT_H)
# Find size of short, int and long types # 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}) set(GMIO_HAVE_LONG_LONG ${HAVE_GMIO_SIZEOF_LONG_LONG})
endif() endif()
# Check C99 features # Check Available C99 features
if(NOT GMIO_BUILD_STRICT_C90) if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE)
if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE) list(APPEND CMAKE_REQUIRED_LIBRARIES m) # -lm
list(APPEND CMAKE_REQUIRED_LIBRARIES m) # -lm endif()
endif() check_function_exists(powf GMIO_HAVE_POWF_FUNC)
check_function_exists(powf GMIO_HAVE_POWF_FUNC) check_function_exists(sqrtf GMIO_HAVE_SQRTF_FUNC)
check_function_exists(sqrtf GMIO_HAVE_SQRTF_FUNC) check_function_exists(strtof GMIO_HAVE_STRTOF_FUNC)
check_function_exists(strtof GMIO_HAVE_STRTOF_FUNC) check_symbol_exists(isfinite math.h GMIO_HAVE_ISFINITE_MACRO)
check_symbol_exists(isfinite math.h GMIO_HAVE_ISFINITE_MACRO) check_symbol_exists(isnan math.h GMIO_HAVE_ISNAN_MACRO)
check_symbol_exists(isnan math.h GMIO_HAVE_ISNAN_MACRO) set(CMAKE_REQUIRED_LIBRARIES) # Pop changes
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) check_function_exists(snprintf GMIO_HAVE_SNPRINTF_FUNC)
if(WIN32 AND NOT GMIO_HAVE_SNPRINTF_FUNC) if(WIN32 AND NOT GMIO_HAVE_SNPRINTF_FUNC)
check_function_exists(_snprintf GMIO_HAVE_WIN__SNPRINTF_FUNC) check_function_exists(_snprintf GMIO_HAVE_WIN__SNPRINTF_FUNC)
endif() endif()
check_function_exists(vsnprintf GMIO_HAVE_VSNPRINTF_FUNC) check_function_exists(vsnprintf GMIO_HAVE_VSNPRINTF_FUNC)
if(WIN32 AND NOT GMIO_HAVE_VSNPRINTF_FUNC) if(WIN32 AND NOT GMIO_HAVE_VSNPRINTF_FUNC)
check_function_exists(_vsnprintf GMIO_HAVE_WIN__VSNPRINTF_FUNC) check_function_exists(_vsnprintf GMIO_HAVE_WIN__VSNPRINTF_FUNC)
endif()
endif() endif()
# Check POSIX features # Check POSIX features

View File

@ -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)) 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), 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: Main highlights:

View File

@ -14,12 +14,10 @@ clone_folder: c:\projects\gmio.git
environment: environment:
matrix: matrix:
- APPVEYOR_BUILD_DLL: ON - APPVEYOR_CMAKE_GENERATOR: "Visual Studio 12 2013"
APPVEYOR_CMAKE_GENERATOR: "Visual Studio 12 2013"
APPVEYOR_FLOAT2STR_LIB: std 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 APPVEYOR_FLOAT2STR_LIB: google_doubleconversion
build: build:
@ -32,7 +30,6 @@ build_script:
-G "%APPVEYOR_CMAKE_GENERATOR%" ^ -G "%APPVEYOR_CMAKE_GENERATOR%" ^
-DCMAKE_BUILD_TYPE=%CONFIGURATION% ^ -DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
-DCMAKE_DEBUG_POSTFIX=_d ^ -DCMAKE_DEBUG_POSTFIX=_d ^
-DGMIO_BUILD_DLL=%APPVEYOR_BUILD_DLL% ^
-DGMIO_FLOAT2STR_LIB=%APPVEYOR_FLOAT2STR_LIB% ^ -DGMIO_FLOAT2STR_LIB=%APPVEYOR_FLOAT2STR_LIB% ^
-DGMIO_BUILD_EXAMPLES=ON ^ -DGMIO_BUILD_EXAMPLES=ON ^
-DGMIO_BUILD_BENCHMARKS=ON ^ -DGMIO_BUILD_BENCHMARKS=ON ^

View File

@ -3,7 +3,7 @@
* https://github.com/miloyip/itoa-benchmark/src/branchlut.cpp * https://github.com/miloyip/itoa-benchmark/src/branchlut.cpp
* commit #27c6059 * commit #27c6059
* *
* Adapted to be C90 compatible * Adapted to be C99 compatible
*/ */
#include "branchlut.h" #include "branchlut.h"
@ -112,7 +112,7 @@ char* i32toa_branchlut(int32_t value, char* buffer) {
} }
#ifdef GMIO_HAVE_INT64_TYPE #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)) #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_e16 = GMIO_UINT64_C(0x002386f2, 0x6fc10000);
static const uint64_t one_e15 = GMIO_UINT64_C(0x00038d7e, 0xa4c68000); static const uint64_t one_e15 = GMIO_UINT64_C(0x00038d7e, 0xa4c68000);

View File

@ -21,14 +21,6 @@ if [ -n "${TRAVIS_GCC_VERSION}" ]; then
export CXX=g++-$TRAVIS_GCC_VERSION; export CXX=g++-$TRAVIS_GCC_VERSION;
fi 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 if [ -z "${TRAVIS_FLOAT2STR_LIB}" ]; then
export TRAVIS_FLOAT2STR_LIB=std; export TRAVIS_FLOAT2STR_LIB=std;
fi fi
@ -41,8 +33,6 @@ cmake .. -G "Unix Makefiles" \
-DCMAKE_DEBUG_POSTFIX=_d \ -DCMAKE_DEBUG_POSTFIX=_d \
-DCMAKE_BUILD_TYPE=$TRAVIS_BUILD_TYPE \ -DCMAKE_BUILD_TYPE=$TRAVIS_BUILD_TYPE \
-DCMAKE_INSTALL_PREFIX=../install \ -DCMAKE_INSTALL_PREFIX=../install \
-DGMIO_BUILD_DLL=$TRAVIS_BUILD_DLL \
-DGMIO_BUILD_STRICT_C90=$TRAVIS_STRICT_C90 \
-DGMIO_BUILD_EXAMPLES=ON \ -DGMIO_BUILD_EXAMPLES=ON \
-DGMIO_BUILD_BENCHMARKS=ON \ -DGMIO_BUILD_BENCHMARKS=ON \
-DGMIO_BUILD_BENCHMARK_ASSIMP=OFF \ -DGMIO_BUILD_BENCHMARK_ASSIMP=OFF \