aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Puchert <aaronpuchert@alice-dsl.net>2017-11-10 00:04:27 +0100
committerThomas Knudsen <busstoptaktik@users.noreply.github.com>2017-11-10 00:04:27 +0100
commit634184850a85145f20147c84f5a02fcd6df185a2 (patch)
tree99a30242b06b8c3e1386f615c5dbdf38a4c3baaa
parent70550ae21c653cceefc2142fa89d0fb6c99101d9 (diff)
downloadPROJ-634184850a85145f20147c84f5a02fcd6df185a2.tar.gz
PROJ-634184850a85145f20147c84f5a02fcd6df185a2.zip
Ensure C89 compliance and enable more warnings (#650)
* Ensure C89 compliance and enable more warnings According to the contributing guidelines, the library is developed strictly in ANSI C 89. However, this is not enforced. Additionally, we enable more warnings: apart from -Wall and -Wextra we enable a warning that makes sure all enumeration values are covered in a switch statement. When compiling with Clang, we also turn on the warnings -Wc99-extensions and -Wc11-extensions. * Enable all warnings that are used on Travis This makes it easier to notice problems before pushing.
-rw-r--r--CMakeLists.txt14
-rw-r--r--src/PJ_aeqd.c2
-rw-r--r--src/PJ_airy.c2
3 files changed, 16 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d6bbe8ea..f489f4ed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,6 +15,20 @@ cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
project(PROJ4 C)
set(PROJECT_INTERN_NAME PROJ)
+# Set warnings
+if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
+ set(CMAKE_C_FLAGS "/WX ${CMAKE_C_FLAGS}")
+elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
+ set(CMAKE_C_FLAGS "-std=c89 -Wall -Wextra -Wswitch -Werror \
+ -Wunused-parameter -Wmissing-prototypes -Wmissing-declarations -Wformat \
+ -Werror=format-security -Wshadow ${CMAKE_C_FLAGS}")
+elseif("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
+ set(CMAKE_C_FLAGS "-std=c89 -Wall -Wextra -Wswitch -Werror \
+ -Wc99-extensions -Wc11-extensions -Wunused-parameter -Wmissing-prototypes \
+ -Wmissing-declarations -Wformat -Werror=format-security -Wshadow \
+ -Wfloat-conversion ${CMAKE_C_FLAGS}")
+endif()
+
#################################################################################
# PROJ4 CMake modules
#################################################################################
diff --git a/src/PJ_aeqd.c b/src/PJ_aeqd.c
index aa1597e4..c089eed7 100644
--- a/src/PJ_aeqd.c
+++ b/src/PJ_aeqd.c
@@ -35,7 +35,7 @@ enum Mode {
N_POLE = 0,
S_POLE = 1,
EQUIT = 2,
- OBLIQ = 3,
+ OBLIQ = 3
};
struct pj_opaque {
diff --git a/src/PJ_airy.c b/src/PJ_airy.c
index 3b145475..f70e7f7a 100644
--- a/src/PJ_airy.c
+++ b/src/PJ_airy.c
@@ -38,7 +38,7 @@ enum Mode {
N_POLE = 0,
S_POLE = 1,
EQUIT = 2,
- OBLIQ = 3,
+ OBLIQ = 3
};
struct pj_opaque {