Browse Source

Provide a simple/dummy libusb_error_name when it is missing (libusb < 1.0.9)

Luke Dashjr 13 years ago
parent
commit
1c6ffa310c
3 changed files with 12 additions and 0 deletions
  1. 10 0
      compat.h
  2. 1 0
      configure.ac
  3. 1 0
      ft232r.c

+ 10 - 0
compat.h

@@ -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>

+ 1 - 0
configure.ac

@@ -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]
 )

+ 1 - 0
ft232r.c

@@ -14,6 +14,7 @@
 
 #include <libusb-1.0/libusb.h>
 
+#include "compat.h"
 #include "fpgautils.h"
 #include "ft232r.h"
 #include "logging.h"