assert.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include <pikaConfig.h>
  3. namespace pika
  4. {
  5. namespace assert
  6. {
  7. //arguments don't do anything here
  8. void terminate(...);
  9. void assertFunctionDevelopment(
  10. const char *expression,
  11. const char *file,
  12. int line,
  13. const char *comment = nullptr);
  14. void assertFunctionProduction
  15. (
  16. const char *expression,
  17. const char *file,
  18. int line,
  19. const char *comment = nullptr
  20. );
  21. void assertFunctionToLog(
  22. const char *expression,
  23. const char *file,
  24. int line,
  25. const char *comment = nullptr);
  26. }
  27. }
  28. #define PIKA_PERMA_ASSERT(expression, comment) (void)( \
  29. (!!(expression)) || \
  30. (PIKA_INTERNAL_CURRENT_ASSERT_FUNCTION(#expression, \
  31. __FILE__, __LINE__, comment), 0) \
  32. )
  33. #ifdef PIKA_DEVELOPMENT
  34. #define PIKA_DEVELOPMENT_ONLY_ASSERT(expression, comment) (void)( \
  35. (!!(expression)) || \
  36. (pika::assert::assertFunctionDevelopment(#expression, \
  37. __FILE__, __LINE__, comment), 0) \
  38. )
  39. #elif defined(PIKA_PRODUCTION)
  40. #define PIKA_DEVELOPMENT_ONLY_ASSERT(expression, comment)
  41. #endif