/** @file error.h * Module providing error handling macros * * The module implements the assert macro intended to allow catching critical * errors during debug while having no influence in the release code as well as * multiple tool macros to handles other kinds of errors */ #ifndef _ERROR_H_ #define _ERROR_H_ //--includes-------------------------------------------------------------------- #include "debug.h" #define ERROR_ASSERT 1 //--type definitions------------------------------------------------------------ #define error_to_string(arg) #arg #if ERROR_ASSERT #define error_assert(cond) \ do { \ if (!(cond)) { \ debug_error("%s:l%u:%s: %s", __FILE__, __LINE__, __func__, \ error_to_string(cond)); \ while (true) {} \ } \ } while (0) #else #define error_assert(cond) do {} while (0) #endif #if ERROR_ASSERT #define error_trigger(msg, ...) \ do { \ debug_error(msg __VA_OPT__(,) __VA_ARGS__); \ while (true) {} \ } while (0) #else #define error_trigger(msg) do {} while (0) #endif //--functions------------------------------------------------------------------- #endif //_ERROR_H_