xref: /spdk/include/spdk/assert.h (revision a6dbe3721eb3b5990707fc3e378c95e505dd8ab5)
1 /*   SPDX-License-Identifier: BSD-3-Clause
2  *   Copyright (C) 2016 Intel Corporation.
3  *   All rights reserved.
4  */
5 
6 /** \file
7  * Runtime and compile-time assert macros
8  */
9 
10 #ifndef SPDK_ASSERT_H
11 #define SPDK_ASSERT_H
12 
13 #include "spdk/stdinc.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #ifdef static_assert
20 #define SPDK_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
21 #else
22 /**
23  * Compatibility wrapper for static_assert.
24  *
25  * This won't actually enforce the condition when compiled with an environment that doesn't support
26  * C11 static_assert; it is only intended to allow end users with old compilers to build the package.
27  *
28  * Developers should use a recent compiler that provides static_assert.
29  */
30 #define SPDK_STATIC_ASSERT(cond, msg)
31 #endif
32 
33 #ifdef __cplusplus
34 }
35 #endif
36 
37 #endif /* SPDK_ASSERT_H */
38