• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef CASSERT_H
8 #define CASSERT_H
9 
10 #include <cdefs.h>
11 
12 /*******************************************************************************
13  * Macro to flag a compile time assertion. It uses the preprocessor to generate
14  * an invalid C construct if 'cond' evaluates to false.
15  * The following compilation error is triggered if the assertion fails:
16  * "error: size of array 'msg' is negative"
17  * The 'unused' attribute ensures that the unused typedef does not emit a
18  * compiler warning.
19  ******************************************************************************/
20 #define CASSERT(cond, msg)	\
21 	typedef char msg[(cond) ? 1 : -1] __unused
22 
23 #endif /* CASSERT_H */
24