@@ -1,6 +1,16 @@
#ifndef __COMPAT_H__
#define __COMPAT_H__
+#include "config.h"
+
+// NOTE: Nested preprocessor checks since the latter isn't defined at all without the former
+#ifdef HAVE_LIBUSB
+# if ! HAVE_DECL_LIBUSB_ERROR_NAME
+ static char my_libusb_error_name_buf[0x10];
+# define libusb_error_name(x) (sprintf(my_libusb_error_name_buf, "%d", x), my_libusb_error_name_buf)
+# endif
+#endif
#ifdef WIN32
#include <errno.h>
#include <time.h>
@@ -193,6 +193,7 @@ AC_CHECK_LIB(usb-1.0, libusb_init,
AC_DEFINE([HAVE_LIBUSB], [1], [Defined to 1 if libusb is wanted])
USB_LIBS="-lusb-1.0"
USB_FLAGS=""
+ AC_CHECK_DECLS([libusb_error_name],[],[],[#include <libusb-1.0/libusb.h>])
],
[libusb=no]
)
@@ -14,6 +14,7 @@
#include <libusb-1.0/libusb.h>
+#include "compat.h"
#include "fpgautils.h"
#include "ft232r.h"
#include "logging.h"