3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
10 #ifndef __WS_ATTRIBUTES_H__
11 #define __WS_ATTRIBUTES_H__
13 #include "ws_compiler_tests.h"
17 #endif /* __cplusplus */
20 * If we're running GCC or clang define _U_ to be "__attribute__((unused))"
21 * so we can use _U_ to flag unused function parameters and not get warnings
22 * about them. Otherwise, define _U_ to be an empty string so that _U_ used
23 * to flag an unused function parameters will compile with other compilers.
25 * XXX - similar hints for other compilers?
28 /* This includes clang */
29 #define _U_ __attribute__((unused))
30 #elif defined(_MSC_VER)
31 #define _U_ __pragma(warning(suppress:4100))
37 * WS_NORETURN, before a function declaration, means "this function
38 * never returns". (It must go before the function declaration, e.g.
39 * "extern WS_NORETURN func(...)" rather than after the function
40 * declaration, as the MSVC version has to go before the declaration.)
42 #if __has_attribute(noreturn) \
43 || WS_IS_AT_LEAST_GNUC_VERSION(2,5) \
44 || WS_IS_AT_LEAST_SUNC_VERSION(5,9) \
45 || WS_IS_AT_LEAST_XL_C_VERSION(10,1) \
46 || WS_IS_AT_LEAST_HP_C_VERSION(6,10)
48 * Compiler with support for __attribute__((noreturn)), or GCC 2.5 and
49 * later, or Solaris Studio 12 (Sun C 5.9) and later, or IBM XL C 10.1
50 * and later (do any earlier versions of XL C support this?), or
51 * HP aCC A.06.10 and later.
53 #define WS_NORETURN __attribute__((noreturn))
54 #elif defined(_MSC_VER)
58 #define WS_NORETURN __declspec(noreturn)
64 * WS_RETNONNULL, before a function declaration, means "this function
65 * always returns a non-null pointer".
67 #if __has_attribute(returns_nonnull) \
68 || WS_IS_AT_LEAST_GNUC_VERSION(4,9)
69 #define WS_RETNONNULL __attribute__((returns_nonnull))
76 #endif /* __cplusplus */
78 #endif /* __WS_ATTRIBUTES_H__ */