Check.h 715 B

1234567891011121314151617181920212223242526272829
  1. #ifndef CORE_CHECK_H
  2. #define CORE_CHECK_H
  3. #if defined(__STDC_VERSION__) && __STDC_VERSION__ > 202300L
  4. #define check_return [[nodiscard]]
  5. #elif defined(__GNUC__)
  6. #define check_return __attribute__((warn_unused_result))
  7. #else
  8. #error "please add a 'check_return' option"
  9. #endif
  10. #if defined(__GNUC__)
  11. #define check_format(format_index, arg_start_index) \
  12. __attribute__((format(printf, format_index, arg_start_index)))
  13. #else
  14. #error "please add a 'check_format' option"
  15. #endif
  16. #if defined(__GNUC__)
  17. #define likely(x) __builtin_expect(!!(x), 1)
  18. #define unlikely(x) __builtin_expect(!!(x), 0)
  19. #else
  20. #define likely(x) x
  21. #define unlikely(x) x
  22. #endif
  23. #define cbool check_return bool
  24. #endif