cassert.h 781 Bytes
Newer Older
1
2
3
/*
 * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved.
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
7
8
9
10
11
12
 */

#ifndef __CASSERT_H__
#define __CASSERT_H__

/*******************************************************************************
 * Macro to flag a compile time assertion. It uses the preprocessor to generate
 * an invalid C construct if 'cond' evaluates to false.
13
 * The following compilation error is triggered if the assertion fails:
14
 * "error: size of array 'msg' is negative"
15
16
 * The 'unused' attribute ensures that the unused typedef does not emit a
 * compiler warning.
17
 ******************************************************************************/
18
#define CASSERT(cond, msg)	\
19
	typedef char msg[(cond) ? 1 : -1] __unused
20
21

#endif /* __CASSERT_H__ */