shithub: aubio

Download patch

ref: 26bd5e0b04becfb8b7f62f0181898d3f6584701c
parent: 9d6093550ec86e416b0ffde9852f5b8a25c83d7a
author: Paul Brossier <piem@piem.org>
date: Sat Dec 22 19:06:32 EST 2018

[lib] add AUBIO_STRERR to log system error messages

--- a/src/aubio_priv.h
+++ b/src/aubio_priv.h
@@ -62,6 +62,10 @@
 #include <string.h>
 #endif
 
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
 #ifdef HAVE_LIMITS_H
 #include <limits.h> // for CHAR_BIT, in C99 standard
 #endif
@@ -328,6 +332,18 @@
 #define AUBIO_STRERROR(errno,buf,len) strerror_r(errno, buf, len)
 #else
 #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 */