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))
35 * WS_NORETURN, before a function declaration, means "this function
36 * never returns". (It must go before the function declaration, e.g.
37 * "extern WS_NORETURN func(...)" rather than after the function
38 * declaration, as the MSVC version has to go before the declaration.)
40 #if __has_attribute(noreturn) \
41 || WS_IS_AT_LEAST_GNUC_VERSION(2,5) \
42 || WS_IS_AT_LEAST_SUNC_VERSION(5,9) \
43 || WS_IS_AT_LEAST_XL_C_VERSION(10,1) \
44 || WS_IS_AT_LEAST_HP_C_VERSION(6,10)
46 * Compiler with support for __attribute__((noreturn)), or GCC 2.5 and
47 * later, or Solaris Studio 12 (Sun C 5.9) and later, or IBM XL C 10.1
48 * and later (do any earlier versions of XL C support this?), or
49 * HP aCC A.06.10 and later.
51 #define WS_NORETURN __attribute__((noreturn))
52 #elif defined(_MSC_VER)
56 #define WS_NORETURN __declspec(noreturn)
62 * WS_RETNONNULL, before a function declaration, means "this function
63 * always returns a non-null pointer".
65 #if __has_attribute(returns_nonnull) \
66 || WS_IS_AT_LEAST_GNUC_VERSION(4,9)
67 #define WS_RETNONNULL __attribute__((returns_nonnull))
74 #endif /* __cplusplus */
76 #endif /* __WS_ATTRIBUTES_H__ */