[go: up one dir, main page]

File: static_assert.h

package info (click to toggle)
smartmontools 7.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,740 kB
  • sloc: cpp: 49,345; ansic: 9,924; sh: 6,043; makefile: 962
file content (27 lines) | stat: -rw-r--r-- 745 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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