Assert.h 767 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (C) 2009-present, 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_ASSERTIONS_ENABLED 0
  11. #else
  12. namespace anki {
  13. void akassert(const char* exprTxt, const char* file, int line, const char* func);
  14. } // namespace anki
  15. # define ANKI_ASSERT(x) \
  16. do \
  17. { \
  18. if(!(x)) [[unlikely]] \
  19. { \
  20. anki::akassert(#x, ANKI_FILE, __LINE__, ANKI_FUNC); \
  21. ANKI_UNREACHABLE(); \
  22. } \
  23. } while(0)
  24. # define ANKI_ASSERTIONS_ENABLED 1
  25. #endif