check.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #ifdef __cplusplus
  3. extern "C" {
  4. #endif
  5. // Find how to how get function's pretty name
  6. #ifndef __FURI_CHECK_FUNC
  7. // Use g++'s demangled names in C++
  8. #if defined __cplusplus && defined __GNUC__
  9. #define __FURI_CHECK_FUNC __PRETTY_FUNCTION__
  10. // C99 requires the use of __func__
  11. #elif __STDC_VERSION__ >= 199901L
  12. #define __FURI_CHECK_FUNC __func__
  13. // Older versions of gcc don't have __func__ but can use __FUNCTION__
  14. #elif __GNUC__ >= 2
  15. #define __FURI_CHECK_FUNC __FUNCTION__
  16. // failed to detect __func__ support
  17. #else
  18. #define __FURI_CHECK_FUNC ((char*)0)
  19. #endif
  20. #endif
  21. // !__FURI_CHECK_FUNC
  22. // We have two levels of assertion
  23. // One - furi_check, which always runs, the only difference is in the level of debug information
  24. // The second is furi_assert, which doesn't compile in release mode
  25. #define furi_check(__e) ((__e) ? (void)0 : __furi_check())
  26. #ifdef NDEBUG
  27. #define furi_assert(__e) ((void)0)
  28. #else
  29. #define furi_assert(__e) ((__e) ? (void)0 : __furi_check())
  30. #endif
  31. // !NDEBUG
  32. void __furi_check(void);
  33. void __furi_check_debug(const char* file, int line, const char* function, const char* condition);
  34. #ifdef __cplusplus
  35. }
  36. #endif