Check.hpp 602 B

123456789101112131415161718192021
  1. #ifndef CORE_CHECK_HPP
  2. #define CORE_CHECK_HPP
  3. #if defined(__cplusplus) && __cplusplus > 201700L
  4. #define check_return [[nodiscard]]
  5. #elif defined(__STDC_VERSION__) && __STDC_VERSION__ > 202300L
  6. #define check_return [[nodiscard]]
  7. #elif defined(__GNUC__)
  8. #define check_return __attribute__((warn_unused_result))
  9. #else
  10. #error "please add a 'check_return' option"
  11. #endif
  12. #if defined(__GNUC__)
  13. #define check_format(format_index, arg_start_index) \
  14. __attribute__((format(printf, format_index, arg_start_index)))
  15. #else
  16. #error "please add a 'check_format' option"
  17. #endif
  18. #endif