2014-04-17 17:29:58 +01:00
|
|
|
/*
|
2018-08-16 16:52:57 +01:00
|
|
|
* Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved.
|
2014-04-17 17:29:58 +01:00
|
|
|
*
|
2017-05-03 09:38:09 +01:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2014-04-17 17:29:58 +01:00
|
|
|
*/
|
|
|
|
|
2018-11-08 10:20:19 +00:00
|
|
|
#ifndef CASSERT_H
|
|
|
|
#define CASSERT_H
|
2014-04-17 17:29:58 +01:00
|
|
|
|
2018-08-16 16:52:57 +01:00
|
|
|
#include <cdefs.h>
|
|
|
|
|
2014-04-17 17:29:58 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* Macro to flag a compile time assertion. It uses the preprocessor to generate
|
|
|
|
* an invalid C construct if 'cond' evaluates to false.
|
2015-10-14 16:00:23 +01:00
|
|
|
* The following compilation error is triggered if the assertion fails:
|
2014-04-17 17:29:58 +01:00
|
|
|
* "error: size of array 'msg' is negative"
|
2015-10-14 16:00:23 +01:00
|
|
|
* The 'unused' attribute ensures that the unused typedef does not emit a
|
|
|
|
* compiler warning.
|
2014-04-17 17:29:58 +01:00
|
|
|
******************************************************************************/
|
2015-10-14 16:00:23 +01:00
|
|
|
#define CASSERT(cond, msg) \
|
2016-01-14 18:11:05 +00:00
|
|
|
typedef char msg[(cond) ? 1 : -1] __unused
|
2014-04-17 17:29:58 +01:00
|
|
|
|
2018-11-08 10:20:19 +00:00
|
|
|
#endif /* CASSERT_H */
|