YetAnotherCoupler
3.5.2
Loading...
Searching...
No Matches
src
core
yac_assert.h
Go to the documentation of this file.
1
// Copyright (c) 2024 The YAC Authors
2
//
3
// SPDX-License-Identifier: BSD-3-Clause
4
5
#ifndef YAC_ASSERT_H
6
#define YAC_ASSERT_H
7
8
// YAC PUBLIC HEADER START
9
10
void
yac_abort_message
(
char
const
*,
char
const
*,
int
);
11
12
#define die(msg) \
13
yac_abort_message((msg), __FILE__, __LINE__)
14
15
#ifndef YAC_CODE_COVERAGE_TEST
16
#define YAC_ASSERT(exp, msg) \
17
{if(!((exp))) yac_abort_message(((msg)), __FILE__, __LINE__);}
18
19
#define YAC_ASSERT_F(exp, format, ...) \
20
{ \
21
if(!((exp))) { \
22
char msg_buffer[1024]; \
23
int ret = snprintf( \
24
msg_buffer, sizeof(msg_buffer), ((format)), __VA_ARGS__); \
25
if ((ret >= 0) && ((size_t)ret < sizeof(msg_buffer))) \
26
yac_abort_message(((msg_buffer)), __FILE__, __LINE__); \
27
else \
28
yac_abort_message( \
29
"an error occured, but error message could not be " \
30
"generated", __FILE__, __LINE__); \
31
} \
32
}
33
#else
34
#define YAC_ASSERT(exp, msg) {(void)(exp);}
35
#define YAC_ASSERT_F(exp, format, ...) {(void)(exp);}
36
#endif
37
38
// YAC PUBLIC HEADER STOP
39
40
#endif
// YAC_ASSERT_H
41
yac_abort_message
void yac_abort_message(char const *, char const *, int)
Generated on Wed Dec 4 2024 11:31:43 for YetAnotherCoupler by
1.11.0