1bdbfc3c2SDan Handley /* 2*93c78ed2SAntonio Nino Diaz * 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 7bdbfc3c2SDan Handley #ifndef __CASSERT_H__ 8bdbfc3c2SDan Handley #define __CASSERT_H__ 9bdbfc3c2SDan Handley 10*93c78ed2SAntonio Nino Diaz #include <cdefs.h> 11*93c78ed2SAntonio 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 23bdbfc3c2SDan Handley #endif /* __CASSERT_H__ */ 24