assert.h 619 B

123456789101112131415161718192021
  1. /*
  2. * Copyright (c) 2012-2014 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE
  4. */
  5. #pragma once
  6. #include <cstdlib>
  7. #include <cstdio>
  8. #include "config.h"
  9. #include "error.h"
  10. #if defined(CROWN_DEBUG)
  11. #define CE_ASSERT(condition, msg, ...) do { if (!(condition)) {\
  12. crown::error::abort(__FILE__, __LINE__, "\nAssertion failed: %s\n\t" msg "\n", #condition, ##__VA_ARGS__); }} while (0)
  13. #else
  14. #define CE_ASSERT(...) ((void)0)
  15. #endif
  16. #define CE_ASSERT_NOT_NULL(x) CE_ASSERT(x != NULL, #x "must be not null")
  17. #define CE_FATAL(msg) CE_ASSERT(false, msg)