Assert.h 764 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Util/Common.h>
  7. /// Assertion. Print an error and stop the debugger (if it runs through a debugger) and then abort.
  8. #if !ANKI_EXTRA_CHECKS
  9. # define ANKI_ASSERT(x) ((void)0)
  10. # define ANKI_ENABLE_ASSERTIONS 0
  11. #else
  12. namespace anki
  13. {
  14. void akassert(const char* exprTxt, const char* file, int line, const char* func);
  15. } // namespace anki
  16. # define ANKI_ASSERT(x) \
  17. do \
  18. { \
  19. if(ANKI_UNLIKELY(!(x))) \
  20. { \
  21. anki::akassert(#x, ANKI_FILE, __LINE__, ANKI_FUNC); \
  22. ANKI_UNREACHABLE(); \
  23. } \
  24. } while(0)
  25. # define ANKI_ENABLE_ASSERTIONS 1
  26. #endif