ic-macros  0.1.5
ic_assert.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023, Intercreate, Inc.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
11 void _ic_assert_fail(const char * file, int line, const char * expr, const char * msg);
12 
18 #define IC_ASSERT(expr, msg...) \
19  (expr) == 0 ? _ic_assert_fail(__FILE__, __LINE__, #expr, ""##msg) : ({})
20 
28 #define IC_ASSERT_CONDITION(expr, condition, msg...) \
29  ({ \
30  __auto_type const _IC_ASSERT_expr_ = (expr); \
31  (_IC_ASSERT_expr_ condition) ? _ic_assert_fail(__FILE__, __LINE__, #expr, ""##msg) \
32  : _IC_ASSERT_expr_; \
33  })