errors.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include <assert.h>
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include <stdio.h>
  6. ////
  7. #include <stdarg.h>
  8. ////
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. ////
  13. // #if (__STDC_VERSION__ >= 201112L)
  14. // #define noreturn _Noreturn
  15. // #else
  16. #define noreturn
  17. // #endif
  18. ////
  19. typedef struct debug_context {
  20. const char *filename;
  21. uint32_t column;
  22. uint32_t line;
  23. } debug_context;
  24. noreturn void error(debug_context context, const char *message, ...);
  25. noreturn void error_no_context(const char *message, ...);
  26. noreturn void error_args(debug_context context, const char *message, va_list args);
  27. noreturn void error_args_no_context(const char *message, va_list args);
  28. void check_function(bool test, debug_context context, const char *message, ...);
  29. #define check(test, context, message, ...) \
  30. assert(test); \
  31. check_function(test, context, message, ##__VA_ARGS__)
  32. void check_args(bool test, debug_context context, const char *message, va_list args);
  33. // V_ASSERT_CONTRACT, assertMacro:check
  34. #ifdef __cplusplus
  35. }
  36. #endif