-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Help compilers to understand the error checking functions
- Loading branch information
1 parent
97327ef
commit 9a9f87c
Showing
2 changed files
with
18 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
#pragma once | ||
|
||
#include <assert.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
|
||
#if (__STDC_VERSION__ >= 201112L) | ||
#define noreturn _Noreturn | ||
#else | ||
#define noreturn | ||
#endif | ||
|
||
typedef struct debug_context { | ||
const char *filename; | ||
uint32_t column; | ||
uint32_t line; | ||
} debug_context; | ||
|
||
void error(debug_context context, const char *message, ...); | ||
void error_args(debug_context context, const char *message, va_list args); | ||
void check(bool check, debug_context context, const char *message, ...); | ||
void check_args(bool check, debug_context context, const char *message, va_list args); | ||
noreturn void error(debug_context context, const char *message, ...); | ||
noreturn void error_args(debug_context context, const char *message, va_list args); | ||
void check_function(bool test, debug_context context, const char *message, ...); | ||
#define check(test, context, message, ...) \ | ||
assert(test); \ | ||
check_function(test, context, message, __VA_ARGS__) | ||
void check_args(bool test, debug_context context, const char *message, va_list args); |