From 39ec5f8ec20a5ee0c916629e4556ab16270f0208 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sat, 8 Dec 2018 12:11:23 +0100 Subject: 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 Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'CMakeLists.txt') 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() -- cgit v1.2.3