check.h 735 B

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. #ifdef __cplusplus
  3. extern "C" {
  4. #define FURI_NORETURN [[noreturn]]
  5. #else
  6. #include <stdnoreturn.h>
  7. #define FURI_NORETURN noreturn
  8. #endif
  9. /** Check condition and crash if check failed */
  10. #define furi_check(__e) ((__e) ? (void)0 : furi_crash("furi_check failed\r\n"))
  11. /** Only in debug build: Assert condition and crash if assert failed */
  12. #ifdef FURI_DEBUG
  13. #define furi_assert(__e) ((__e) ? (void)0 : furi_crash("furi_assert failed\r\n"))
  14. #else
  15. #define furi_assert(__e) \
  16. do { \
  17. ((void)(__e)); \
  18. } while(0)
  19. #endif
  20. /** Crash system */
  21. FURI_NORETURN void furi_crash(const char* message);
  22. /** Halt system */
  23. FURI_NORETURN void furi_halt(const char* message);
  24. #ifdef __cplusplus
  25. }
  26. #endif