1 | /* -*- tab-width: 4; -*- */ |
2 | /* vi: set sw=2 ts=4 expandtab: */ |
3 | |
4 | /* Copyright 2019-2018 The Khronos Group Inc. |
5 | * SPDX-License-Identifier: Apache-2.0 |
6 | */ |
7 | |
8 | /* I'm extending this beyond the purpose implied by its name rather than creating |
9 | * a new file to hold the FALLTHROUGH declaration as this |
10 | * file is already included in most places FALLTHROUGH |
11 | * is needed. |
12 | */ |
13 | |
14 | #ifndef _UNUSED_H |
15 | #define _UNUSED_H |
16 | |
17 | #if (__cplusplus >= 201703L) |
18 | #define MAYBE_UNUSED [[maybe_unused]] |
19 | #elif __GNUC__ || __clang__ |
20 | #define MAYBE_UNUSED __attribute__((unused)) |
21 | #else |
22 | // Boohoo. VC++ has no equivalent |
23 | #define MAYBE_UNUSED |
24 | #endif |
25 | |
26 | #define U_ASSERT_ONLY MAYBE_UNUSED |
27 | |
28 | // For unused parameters of c functions. Portable. |
29 | #define UNUSED(x) (void)(x) |
30 | |
31 | #if !__clang__ && __GNUC__ // grumble ... clang ... grumble |
32 | #define FALLTHROUGH __attribute__((fallthrough)) |
33 | #else |
34 | #define FALLTHROUGH |
35 | #endif |
36 | |
37 | #endif /* UNUSED_H */ |
38 | |