From 57b2a84f3d900eb0b98157095c6aac07cec54fd9 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Tue, 5 Apr 2016 22:49:05 +0200 Subject: Use a single WS_NORETURN macro Having to define two macros for marking a function as never returning seems a bit redundant. Merge the MSVC and GCC-like attributes into a single WS_NORETURN. Tested with Clang 3.7.1, GCC 4.4.7 and even GCC 4.1.2 using this small program (-Wall -Wextra, the first two generate warnings for uninitialized variables, the last one compiles without warnings): #include __attribute__((noreturn)) void foo() { exit(1); } __attribute__((noreturn)) void bar(); void bar() { exit(1); } int main() { int j, i; if (i) { bar(); return j; } foo(); return j; } Change-Id: I7d19c15e61b8f8fa4936864407199c4109f8cc82 Reviewed-on: https://code.wireshark.org/review/14822 Petri-Dish: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris Reviewed-by: Peter Wu --- cmakeconfig.h.in | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'cmakeconfig.h.in') diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in index 75d9433582..bb62fb6737 100644 --- a/cmakeconfig.h.in +++ b/cmakeconfig.h.in @@ -415,15 +415,6 @@ #cmakedefine _LARGE_FILES #cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@ -/* Define WS_MSVC_NORETURN appropriately for declarations of routines that - never return (just like Charlie on the MTA). - - Note that MSVC++ expects __declspec(noreturn) to precede the function - name and GCC, as far as I know, expects __attribute__((noreturn)) to - follow the function name, so we need two different flavors of - noreturn tag. */ -#define WS_MSVC_NORETURN @WS_MSVC_NORETURN@ - /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a `char[]'. */ /* Note: not use in the code */ @@ -433,6 +424,9 @@ However, we do need it for some headers that are shared between C and C++. */ #define _U_ ${C_UNUSED} +/* Hint to the compiler that a function never returns */ +#define WS_NORETURN @WS_NORETURN@ + #if defined(_WIN32) /* WpdPack/INclude/pcap/pcap.h checks for "#if defined(WIN32)" */ -- cgit v1.2.3