summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2018-01-18 13:35:09 +0100
committerGitHub <[email protected]>2018-01-18 13:35:09 +0100
commit5931bd501cb671854a85b4312bd4da614b6c8797 (patch)
treee19d5ae87aabb65d1662ef558524f2d3e3f8e495
parenta2edc9d64191d9b9253ee7faa5f80cd742f769b2 (diff)
parent30ef3f3122dc05e8a950d21c4b098208d73e456b (diff)
downloadraylib-5931bd501cb671854a85b4312bd4da614b6c8797.tar.gz
raylib-5931bd501cb671854a85b4312bd4da614b6c8797.zip
Merge pull request #433 from a3f/develop
GCC/Clang: Treat void pointer arithmetic as error
-rw-r--r--CMakeLists.txt5
-rw-r--r--src/Makefile21
2 files changed, 16 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 057481bd..82a1ad32 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
diff --git a/src/Makefile b/src/Makefile
index fbab6725..f27ec575 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -250,16 +250,17 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
endif
# Define compiler flags:
-# -O1 defines optimization level
-# -g enable debugging
-# -s strip unnecessary data from build
-# -Wall turns on most, but not all, compiler warnings
-# -std=c99 defines C language mode (standard C from 1999 revision)
-# -std=gnu99 defines C language mode (GNU C from 1999 revision)
-# -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
+# -O1 defines optimization level
+# -g enable debugging
+# -s strip unnecessary data from build
+# -Wall turns on most, but not all, compiler warnings
+# -std=c99 defines C language mode (standard C from 1999 revision)
+# -std=gnu99 defines C language mode (GNU C from 1999 revision)
+# -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
+# -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