alassert.h 704 B

123456789101112131415161718192021222324
  1. #ifndef AL_ASSERT_H
  2. #define AL_ASSERT_H
  3. #include <array>
  4. #include "opthelpers.h"
  5. namespace al {
  6. [[noreturn]]
  7. void do_assert(const char *message, int linenum, const char *filename, const char *funcname) noexcept;
  8. } /* namespace al */
  9. /* A custom assert macro that is not compiled out for Release/NDEBUG builds,
  10. * making it an appropriate replacement for assert() checks that must not be
  11. * ignored.
  12. */
  13. #define alassert(cond) do { \
  14. if(!(cond)) UNLIKELY \
  15. al::do_assert("Assertion '" #cond "' failed", __LINE__, __FILE__, std::data(__func__)); \
  16. } while(0)
  17. #endif /* AL_ASSERT_H */