diff --git a/qpms/qpms_error.h b/qpms/qpms_error.h index 55dff9d..20628ac 100644 --- a/qpms/qpms_error.h +++ b/qpms/qpms_error.h @@ -72,16 +72,22 @@ qpms_dbgmsg_flags qpms_dbgmsg_enable(qpms_dbgmsg_flags types); #define QPMS_WTF qpms_pr_error_at_flf(__FILE__,__LINE__,__func__,"Unexpected error.") #define QPMS_UNTESTED {\ - static bool already_bitched = false; \ + static _Bool already_bitched = 0; \ if (!already_bitched) {\ qpms_warn_at_flf(__FILE__,__LINE__,__func__,"Warning: untested function/feature!");\ - already_bitched = true;\ + already_bitched = 1;\ }\ } #define QPMS_PR_ERROR(msg, ...) qpms_pr_error_at_flf(__FILE__,__LINE__,__func__,msg, ##__VA_ARGS__) -#define QPMS_ENSURE_SUCCESS(x) {if(x) QPMS_WTF;} +// TODO replace this macro with an inline function? +#define QPMS_ENSURE_SUCCESS(x) { \ + int errorcode = (x); \ + if(errorcode) \ + qpms_pr_error_at_flf(__FILE__,__LINE__,__func__,"Unexpected error (%d)", errorcode); \ +} + #define QPMS_ENSURE(x, msg, ...) {if(!(x)) qpms_pr_error_at_flf(__FILE__,__LINE__,__func__,msg, ##__VA_ARGS__); } @@ -95,10 +101,10 @@ qpms_dbgmsg_flags qpms_dbgmsg_enable(qpms_dbgmsg_flags types); "Not implemented:" msg, ##__VA_ARGS__) #define QPMS_INCOMPLETE_IMPLEMENTATION(msg, ...) {\ - static bool already_bitched = false; \ + static _Bool already_bitched = 0; \ if (!already_bitched) {\ qpms_warn_at_flf(__FILE__,__LINE__,__func__,msg, ##__VA_ARGS__);\ - already_bitched = true;\ + already_bitched = 1;\ }\ }