1 /* 2 * static_assert.h 3 * 4 * Home page of code is: https://www.smartmontools.org 5 * 6 * Copyright (C) 2019 Christian Franke 7 * 8 * SPDX-License-Identifier: GPL-2.0-or-later 9 */ 10 11 #ifndef STATIC_ASSERT_H 12 #define STATIC_ASSERT_H 13 14 #define STATIC_ASSERT_H_CVSID "$Id: static_assert.h 4934 2019-07-01 20:54:14Z chrfranke $" 15 16 #if __cplusplus >= 201103 || _MSVC_LANG >= 201103 17 #define STATIC_ASSERT(x) static_assert((x), #x) 18 #elif __STDC_VERSION__ >= 201112 19 #define STATIC_ASSERT(x) _Static_assert((x), #x) 20 #elif __GNUC__ >= 4 21 #define STATIC_ASSERT(x) typedef char static_assertion[(x) ? 1 : -1] \ 22 __attribute__((unused)) 23 #else 24 #define STATIC_ASSERT(x) typedef char static_assertion[(x) ? 1 : -1] 25 #endif 26 27 #endif // STATIC_ASSERT_H 28