File syn_assert.h¶
File List > src > syntropic > util > syn_assert.h
Go to the documentation of this file
#ifndef SYN_ASSERT_H
#define SYN_ASSERT_H
#include "../common/syn_compiler.h"
#ifdef __cplusplus
extern "C" {
#endif
SYN_NORETURN void syn_assert_failed(const char *file, int line);
#ifndef SYN_DISABLE_ASSERT
#ifdef __CPPCHECK__
/* Tell cppcheck that assertion failures halt execution */
void abort(void);
#define SYN_ASSERT(expr) \
do { \
if (!(expr)) { \
abort(); \
} \
} while (0)
#else
#define SYN_ASSERT(expr) \
do { \
if (!(expr)) { \
syn_assert_failed(__FILE__, __LINE__); \
} \
} while (0)
#endif
#else
#define SYN_ASSERT(expr) ((void)0)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SYN_ASSERT_H */