From: Paul Brossier Date: Sat, 22 Dec 2018 23:06:32 +0000 (+0100) Subject: [lib] add AUBIO_STRERR to log system error messages X-Git-Tag: 0.4.9~23 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=26bd5e0b04becfb8b7f62f0181898d3f6584701c;p=aubio.git [lib] add AUBIO_STRERR to log system error messages --- 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))