YAC 3.21.0
Yet Another Coupler
Loading...
Searching...
No Matches
yac_assert.h File Reference
#include <stdio.h>
Include dependency graph for yac_assert.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define die(msg)    yac_abort_message((msg), __FILE__, __LINE__)
 
#define YAC_ASSERT(exp, msg)    YAC_ASSERT_F((exp), "%s", (msg))
 
#define YAC_ASSERT_FUNC(exp, func, msg)    YAC_ASSERT_F_FUNC((exp), (func), "%s", (msg))
 
#define YAC_ASSERT_F(exp, format, ...)    YAC_ASSERT_F_FUNC((exp), __func__, format, ##__VA_ARGS__)
 
#define YAC_ASSERT_F_FUNC(exp, func, format, ...)
 
#define YAC_UNREACHABLE_DEFAULT(msg)
 
#define YAC_UNREACHABLE_DEFAULT_F_FUNC(func, format, ...)
 
#define YAC_UNREACHABLE_DEFAULT_F(format, ...)    YAC_UNREACHABLE_DEFAULT_F_FUNC(__func__, format, ##__VA_ARGS__)
 
#define YAC_UNREACHABLE(msg)    YAC_ASSERT(0, (msg));
 
#define YAC_UNREACHABLE_F(format, ...)    YAC_ASSERT_F(0, format, ##__VA_ARGS__)
 

Functions

void yac_abort_message (char const *, char const *, int)
 

Macro Definition Documentation

◆ die

#define die ( msg)     yac_abort_message((msg), __FILE__, __LINE__)

Definition at line 14 of file yac_assert.h.

◆ YAC_ASSERT

#define YAC_ASSERT ( exp,
msg )    YAC_ASSERT_F((exp), "%s", (msg))

Definition at line 33 of file yac_assert.h.

◆ YAC_ASSERT_F

#define YAC_ASSERT_F ( exp,
format,
... )    YAC_ASSERT_F_FUNC((exp), __func__, format, ##__VA_ARGS__)

Definition at line 39 of file yac_assert.h.

◆ YAC_ASSERT_F_FUNC

#define YAC_ASSERT_F_FUNC ( exp,
func,
format,
... )
Value:
{ \
if(!((exp))) { \
char msg_buffer[1024]; \
int ret = snprintf( \
msg_buffer, sizeof(msg_buffer), \
"ERROR(%s): " format, (func), ##__VA_ARGS__); \
if ((ret >= 0) && ((size_t)ret < sizeof(msg_buffer))) \
die(msg_buffer); \
else \
die("an error occurred, but error message could not be generated"); \
} \
}

Definition at line 42 of file yac_assert.h.

◆ YAC_ASSERT_FUNC

#define YAC_ASSERT_FUNC ( exp,
func,
msg )    YAC_ASSERT_F_FUNC((exp), (func), "%s", (msg))

Definition at line 36 of file yac_assert.h.

◆ YAC_UNREACHABLE

#define YAC_UNREACHABLE ( msg)     YAC_ASSERT(0, (msg));

Definition at line 82 of file yac_assert.h.

◆ YAC_UNREACHABLE_DEFAULT

#define YAC_UNREACHABLE_DEFAULT ( msg)
Value:
default: \
{ \
YAC_UNREACHABLE(msg); \
__attribute__((fallthrough)); \
}

Definition at line 56 of file yac_assert.h.

◆ YAC_UNREACHABLE_DEFAULT_F

#define YAC_UNREACHABLE_DEFAULT_F ( format,
... )    YAC_UNREACHABLE_DEFAULT_F_FUNC(__func__, format, ##__VA_ARGS__)

Definition at line 77 of file yac_assert.h.

◆ YAC_UNREACHABLE_DEFAULT_F_FUNC

#define YAC_UNREACHABLE_DEFAULT_F_FUNC ( func,
format,
... )
Value:
default: \
{ \
char msg_buffer[1024]; \
int ret = snprintf( \
msg_buffer, sizeof(msg_buffer), \
"ERROR(%s): " format, (func), ##__VA_ARGS__); \
if ((ret >= 0) && ((size_t)ret < sizeof(msg_buffer))) \
die(msg_buffer); \
else \
die("an error occurred, but error message could not be generated"); \
__attribute__((fallthrough)); \
}

Definition at line 63 of file yac_assert.h.

◆ YAC_UNREACHABLE_F

#define YAC_UNREACHABLE_F ( format,
... )    YAC_ASSERT_F(0, format, ##__VA_ARGS__)

Definition at line 85 of file yac_assert.h.

Function Documentation

◆ yac_abort_message()

void yac_abort_message ( char const * ,
char const * ,
int  )