aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-12-08 12:11:23 +0100
committerAnders Broman <a.broman58@gmail.com>2018-12-09 07:13:16 +0000
commit39ec5f8ec20a5ee0c916629e4556ab16270f0208 (patch)
tree401923759c0c58c28e39b1b5334781ef4c55c3e2 /CMakeLists.txt
parent4160f1017fe1432f415679873a2db29bc17a4eca (diff)
CMake: allow nested structures to be initialized via { 0 }
This is already permitted since C89 and popular compilers seem to support it (including Clang 3.0 - 7.0, GCC 4.1.2 - 8.2 and MSVC 2015). GCC used to be buggy: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119 C89 6.5.7. Initialization: "only enough initializers from the list are taken to account for the members of the subaggregate". Change-Id: Ic59b9fe71e2d3ce60b4b7d1074f8d84af01a817a Reviewed-on: https://code.wireshark.org/review/30968 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt9
1 files changed, 7 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c755b156c3..6479a1c100 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -612,10 +612,15 @@ else() # ! MSVC
# structures with multiple members is perfectly legal, but some older
# compilers warn about it. Silence those older compilers.
#
- if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "4.7") OR
+ if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "5.1") OR
(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0") OR
(CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "10.0"))
- list(APPEND WIRESHARK_C_ONLY_FLAGS -Wno-missing-field-initializers)
+ if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_VERSION VERSION_LESS "4.7")
+ list(APPEND WIRESHARK_C_ONLY_FLAGS -Wno-missing-field-initializers)
+ endif()
+ # Silence warnings for initialization of nested structs like
+ # struct { struct { int a, b; } s; int c; } v = { 0 };
+ list(APPEND WIRESHARK_C_ONLY_FLAGS -Wno-missing-braces)
endif()