Merge pull request #433 from a3f/develop

GCC/Clang: Treat void pointer arithmetic as error
This commit is contained in:
Ray 2018-01-18 13:35:09 +01:00 committed by GitHub
commit 5931bd501c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 10 deletions

View File

@ -11,6 +11,11 @@ if(CMAKE_VERSION VERSION_LESS "3.1")
else()
set (CMAKE_C_STANDARD 99)
endif()
include(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG("-Werror=pointer-arith" COMPILER_HAS_POINTER_ARITH_TOGGLE)
if(COMPILER_HAS_POINTER_ARITH_TOGGLE)
set(CMAKE_C_FLAGS "-Werror=pointer-arith ${CMAKE_C_FLAGS}")
endif()
add_subdirectory(src release)

View File

@ -259,7 +259,8 @@ endif
# -fgnu89-inline declaring inline functions support (GCC optimized)
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
CFLAGS += -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces
# -Werror=pointer-arith catch unportable code that does direct arithmetic on void pointers
CFLAGS += -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith
# Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes