diff options
Diffstat (limited to '')
-rw-r--r-- | static_assert.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/static_assert.h b/static_assert.h new file mode 100644 index 0000000..06bfaa2 --- /dev/null +++ b/static_assert.h @@ -0,0 +1,27 @@ +/* + * static_assert.h + * + * Home page of code is: https://www.smartmontools.org + * + * Copyright (C) 2019 Christian Franke + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef STATIC_ASSERT_H +#define STATIC_ASSERT_H + +#define STATIC_ASSERT_H_CVSID "$Id: static_assert.h 4934 2019-07-01 20:54:14Z chrfranke $" + +#if __cplusplus >= 201103 || _MSVC_LANG >= 201103 +#define STATIC_ASSERT(x) static_assert((x), #x) +#elif __STDC_VERSION__ >= 201112 +#define STATIC_ASSERT(x) _Static_assert((x), #x) +#elif __GNUC__ >= 4 +#define STATIC_ASSERT(x) typedef char static_assertion[(x) ? 1 : -1] \ + __attribute__((unused)) +#else +#define STATIC_ASSERT(x) typedef char static_assertion[(x) ? 1 : -1] +#endif + +#endif // STATIC_ASSERT_H |