diff options
author | Jose Fonseca <jfonseca@vmware.com> | 2015-03-03 13:39:19 +0000 |
---|---|---|
committer | Jose Fonseca <jfonseca@vmware.com> | 2015-03-03 14:18:29 +0000 |
commit | 0f31aac49a6f9557c943a955c275ab426d33cf5f (patch) | |
tree | dbc7b72b352cb1cc79ddd7af99348773892fd75a | |
parent | 188f2deb6052433947fa12cc1326514999eb64b6 (diff) |
cmake: Use -Werror=pointer-arith on GCC builds.
Void pointer arithmetic is not supported on MSVC, so passing
-Werror=pointer-arith will make it easier for everybody to catch this
sort of portability issues as the code is written.
Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
-rw-r--r-- | CMakeLists.txt | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 94c0958f2..19028cbb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -215,6 +215,12 @@ if (NOT MSVC) IF (C_COMPILER_FLAG_WEVLA) SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=vla") ENDIF () + # GCC allows void pointer arithmetic, but it is not part of ISO C and + # in particular MSVC will throw `C2036: 'void *' : unknown size` + check_c_compiler_flag ("-Werror=pointer-arith" C_COMPILER_FLAG_WEPOINTER_ARITH) + if (C_COMPILER_FLAG_WEPOINTER_ARITH) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=pointer-arith") + endif () # MSVC only supports C99 variadic macros. It doesn't support the # non-standard GNU named variadic macro syntax that's documented in # https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html |