From 8be93762d9a94a56bf430e0e177bdefb5b1fa0dd Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Thu, 25 Jan 2018 22:34:29 +0100 Subject: [PATCH] Make function calls without prior declaration an error which is the default behavior on C99 and up. --- CMakeLists.txt | 14 ++++++++++---- src/Makefile | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) mode change 100644 => 100755 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 82a1ad32..11db057e --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,10 +12,16 @@ 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() +foreach(option -Werror=pointer-arith;-Werror=implicit-function-declaration) + CHECK_C_COMPILER_FLAG("${option}" COMPILER_HAS_THOSE_TOGGLES) + set(outcome "Failed") + if(COMPILER_HAS_THOSE_TOGGLES) + set(CMAKE_C_FLAGS "${option} ${CMAKE_C_FLAGS}") + set(outcome "works") + endif() + message(STATUS "Testing if ${option} can be used -- ${outcome}") +endforeach() + add_subdirectory(src release) diff --git a/src/Makefile b/src/Makefile index c88aa6dd..fc85ea0a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -262,7 +262,8 @@ endif # -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 +# -Werror=implicit-function-declaration catch function calls without prior declaration +CFLAGS += -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith -Werror=implicit-function-declaration ifeq ($(RAYLIB_BUILD_MODE), DEBUG) CFLAGS += -g