From 26bd5e0b04becfb8b7f62f0181898d3f6584701c Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sun, 23 Dec 2018 00:06:32 +0100 Subject: [PATCH] [lib] add AUBIO_STRERR to log system error messages --- src/aubio_priv.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/aubio_priv.h b/src/aubio_priv.h index fa59571e..ab6afb28 100644 --- a/src/aubio_priv.h +++ b/src/aubio_priv.h @@ -62,6 +62,10 @@ #include #endif +#ifdef HAVE_ERRNO_H +#include +#endif + #ifdef HAVE_LIMITS_H #include // for CHAR_BIT, in C99 standard #endif @@ -330,6 +334,18 @@ uint_t aubio_log(sint_t level, const char_t *fmt, ...); #define AUBIO_STRERROR(errno,buf,len) strerror_s(buf, len, errno) #endif +#ifdef HAVE_C99_VARARGS_MACROS +#define AUBIO_STRERR(...) \ + char errorstr[256]; \ + AUBIO_STRERROR(errno, errorstr, sizeof(errorstr)); \ + AUBIO_ERR(__VA_ARGS__) +#else +#define AUBIO_STRERR(format, args...) \ + char errorstr[256]; \ + AUBIO_STRERROR(errno, errorstr, sizeof(errorstr)); \ + AUBIO_ERR(format, ##args) +#endif + /* handy shortcuts */ #define DB2LIN(g) (POW(10.0,(g)*0.05f)) #define LIN2DB(v) (20.0*LOG10(v)) -- 2.11.0