cassert.h 794 B

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