Make missing prototypes warning work in clang/C++. in GCC, -Wmissing-prototypes is only in C and the C++ spelling is -Wmissing-declarations. https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Warning-Options.html#Warning-Options In clang, -Wmissing-prototypes is in both C/C++ and -Wmissing-declarations means you forgot to name a typedef or something? https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-prototypes https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-declarations Pass clang slightly different flags to account for this mess. Change-Id: I574ff7ecf32ba5908355639de83e8a102dab5f04 Reviewed-on: https://boringssl-review.googlesource.com/17784 Reviewed-by: Steven Valdez <svaldez@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt index deab75b..a71ebf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -43,6 +43,16 @@ endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_CXX_FLAGS} -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${C_CXX_FLAGS} -Wmissing-declarations") + # In GCC, -Wmissing-declarations is the C++ spelling of -Wmissing-prototypes + # and using the wrong one is an error. In Clang, -Wmissing-prototypes is the + # spelling for both and -Wmissing-declarations is some other warning. + # + # https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Warning-Options.html#Warning-Options + # https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-prototypes + # https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-declarations + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-prototypes") + endif() elseif(MSVC) set(MSVC_DISABLED_WARNINGS_LIST "C4061" # enumerator 'identifier' in switch of enum 'enumeration' is not