error.h 807 B

1234567891011121314151617181920212223242526
  1. /*
  2. * Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE
  4. */
  5. #pragma once
  6. namespace crown
  7. {
  8. namespace error
  9. {
  10. /// Aborts the program execution logging an error message and the stacktrace if
  11. /// the platform supports it.
  12. void abort(const char* file, int line, const char* message, ...);
  13. } // namespace error
  14. } // namespace crown
  15. #if CROWN_DEBUG
  16. #define CE_ASSERT(condition, msg, ...) do { if (!(condition)) {\
  17. crown::error::abort(__FILE__, __LINE__, "\nAssertion failed: %s\n\t" msg "\n", #condition, ##__VA_ARGS__); }} while (0)
  18. #else
  19. #define CE_ASSERT(...) ((void)0)
  20. #endif // CROWN_DEBUG
  21. #define CE_ASSERT_NOT_NULL(x) CE_ASSERT(x != NULL, #x " must be not null")
  22. #define CE_FATAL(msg) CE_ASSERT(false, msg)