Assert.h 1.1 KB

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