diff options
author | Peter Wu <peter@lekensteyn.nl> | 2016-08-31 15:58:20 +0200 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-09-06 02:42:27 +0000 |
commit | 232a8794293bf654fb61122adffa6a7aa2989cc0 (patch) | |
tree | fdc95cf5894c7515f880c7974ccff36f3e2ae8d8 /CMakeLists.txt | |
parent | 5eb9170227a590560003dfc3b654e7be1b942b9a (diff) | |
download | wireshark-232a8794293bf654fb61122adffa6a7aa2989cc0.tar.gz |
Allow a lot more C99 features
Flexible array members are supported by gcc, clang and even MSVC2013.
Note, so far it was only used in the Windows-specific airpcap.h.
Trailing commas in enum declaration are already in use since for
these dissectors (commit ID is the first occurrence):
epan/dissectors/packet-gluster.h v2.1.0rc0-1070-g3b706ba
epan/dissectors/packet-ipv6.c v2.1.2rc0-81-ge07b4aa
epan/dissectors/packet-netlink.h v2.3.0rc0-389-gc0ab12b
epan/dissectors/packet-netlink-netfilter.c v2.3.0rc0-239-g1767e08
epan/dissectors/packet-netlink-route.c v2.3.0rc0-233-g2a80b40
epan/dissectors/packet-quic.c v2.3.0rc0-457-gfa320f8
Inline functions using the "inline" keyword are supported via all glib
versions we support (if it is missing, glib will define a suitable
inline macro).
Other c99 functions listed in the README.developer document were found
to be compatible with GCC 4.4.7, Clang 3.4.2 and MSVC 2013.
Change-Id: If5bab03bfd8577b15a24bedf08c03bdfbf34317a
Reviewed-on: https://code.wireshark.org/review/17421
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ec6dc1370b..5b09c508a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -308,7 +308,9 @@ if( CMAKE_C_COMPILER_ID MATCHES "MSVC") # when compiling Wireshark sources. (Selected from "level 4" warnings). ## 4295: array is too small to include a terminating null character ## 4189: local variable is initialized but not referenced - set(WARNINGS_CFLAGS "/w34295 /w34189") + # Disable warnings about about use of flexible array members: + ## 4200: nonstandard extension used : zero-sized array in struct/union + set(WARNINGS_CFLAGS "/w34295 /w34189 /wd4200") set(WIRESHARK_COMMON_FLAGS ${LOCAL_CFLAGS} @@ -343,6 +345,17 @@ else() endif() endif() + if(CMAKE_VERSION VERSION_LESS "3.1") + # Many modern compilers use c99 by default, but for older ones + # (like GCC 4.4.7), -std=gnu99 is required to avoid errors about + # use constructs like "for (int i = 0; i < n; i++) ;" + if(CMAKE_C_COMPILER_ID MATCHES "GNU") + set(CMAKE_C_FLAGS "-std=gnu99 ${CMAKE_C_FLAGS}") + endif() + else() + set(CMAKE_C_STANDARD 99) + endif() + if(CMAKE_C_COMPILER_ID MATCHES "Clang") set(WIRESHARK_COMMON_FLAGS ${WIRESHARK_COMMON_FLAGS} # avoid "argument unused during compilation" warnings @@ -391,8 +404,6 @@ else() # The Qt headers generate a ton of shortening errors on 64-bit systems # so only enable this for C for now. -Wshorten-64-to-32 - # Clang only - -Wc99-extensions ) set(CXX_WARN_FLAGS |