YetAnotherCoupler 3.2.0_a
Loading...
Searching...
No Matches
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
10void yac_abort_message(char const*, char const*, int);
11
12#define die(msg) \
13 yac_abort_message((msg), __FILE__, __LINE__)
14
15#define YAC_ASSERT(exp, msg) \
16 {if(!((exp))) yac_abort_message(((msg)), __FILE__, __LINE__);}
17
18#define YAC_ASSERT_F(exp, format, ...) \
19 { \
20 if(!((exp))) { \
21 char msg_buffer[1024]; \
22 int ret = snprintf( \
23 msg_buffer, sizeof(msg_buffer), ((format)), __VA_ARGS__); \
24 if ((ret >= 0) && ((size_t)ret < sizeof(msg_buffer))) \
25 yac_abort_message(((msg_buffer)), __FILE__, __LINE__); \
26 else \
27 yac_abort_message( \
28 "an error occured, but error message could not be " \
29 "generated", __FILE__, __LINE__); \
30 } \
31 }
32
33// YAC PUBLIC HEADER STOP
34
35#endif // YAC_ASSERT_H
36
void yac_abort_message(char const *, char const *, int)