assert.h 562 B

123456789101112131415161718
  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 "error.h"
  7. #if defined(CROWN_DEBUG)
  8. #define CE_ASSERT(condition, msg, ...) do { if (!(condition)) {\
  9. crown::error::abort(__FILE__, __LINE__, "\nAssertion failed: %s\n\t" msg "\n", #condition, ##__VA_ARGS__); }} while (0)
  10. #else
  11. #define CE_ASSERT(...) ((void)0)
  12. #endif
  13. #define CE_ASSERT_NOT_NULL(x) CE_ASSERT(x != NULL, #x "must be not null")
  14. #define CE_FATAL(msg) CE_ASSERT(false, msg)