xref: /rk3399_ARM-atf/include/lib/cassert.h (revision 4c700c1563aff7b51df95f17e952e050b9b4e37f)
1bdbfc3c2SDan Handley /*
2*4c700c15SGovindraj Raja  * Copyright (c) 2014-2018, Arm Limited and Contributors. All rights reserved.
3bdbfc3c2SDan Handley  *
482cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
5bdbfc3c2SDan Handley  */
6bdbfc3c2SDan Handley 
7c3cf06f1SAntonio Nino Diaz #ifndef CASSERT_H
8c3cf06f1SAntonio Nino Diaz #define CASSERT_H
9bdbfc3c2SDan Handley 
1093c78ed2SAntonio Nino Diaz #include <cdefs.h>
1193c78ed2SAntonio Nino Diaz 
12bdbfc3c2SDan Handley /*******************************************************************************
13bdbfc3c2SDan Handley  * Macro to flag a compile time assertion. It uses the preprocessor to generate
14bdbfc3c2SDan Handley  * an invalid C construct if 'cond' evaluates to false.
15bdbfc3c2SDan Handley  * The following compilation error is triggered if the assertion fails:
16bdbfc3c2SDan Handley  * "error: size of array 'msg' is negative"
17c17a4dc3SSandrine Bailleux  * The 'unused' attribute ensures that the unused typedef does not emit a
18c17a4dc3SSandrine Bailleux  * compiler warning.
19bdbfc3c2SDan Handley  ******************************************************************************/
20c17a4dc3SSandrine Bailleux #define CASSERT(cond, msg)	\
2165cd299fSSoren Brinkmann 	typedef char msg[(cond) ? 1 : -1] __unused
22bdbfc3c2SDan Handley 
23c3cf06f1SAntonio Nino Diaz #endif /* CASSERT_H */
24