1 /*
2 * Copyright (c) 2018-2021 Dmitry V. Levin <ldv@strace.io>
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7
8 #ifndef STRACE_STATIC_ASSERT_H
9 # define STRACE_STATIC_ASSERT_H
10
11 # include "assert.h"
12
13 # if defined HAVE_STATIC_ASSERT || defined static_assert
14
15 /* static_assert is already available */
16
17 # elif defined HAVE__STATIC_ASSERT
18
19 # undef static_assert
20 # define static_assert _Static_assert
21
22 # else /* !HAVE_STATIC_ASSERT && !HAVE__STATIC_ASSERT */
23
24 /* Otherwise it is impossible to use the fallback inside functions. */
25 # if defined __GNUC__
26 # pragma GCC diagnostic ignored "-Wnested-externs"
27 # endif
28
29 # define static_assert(expr, message) \
30 extern int (*strace_static_assert(int))[sizeof(int[2 * !!(expr) - 1])]
31
32 # endif
33
34 #endif /* !STRACE_STATIC_ASSERT_H */