Both mingw-w64 and libusb-compat define a header called "usb.h". This issue
was sort of discussed on this mailing list five years ago:
https://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/aanlkti%[email protected]/?page=1
Back then, Xiaofan was arguing that mingw-w64 breaks a lot of Linux software
that expects "#include <usb.h>" to bring in the libusb-compat library's header
file instead of the mingw-w64 header file. I actually am having the opposite
problem: MSYS2 installs libusb-compat's usb.h inside /mingw64/include/, which
has a higher precendence than the mingw-w64 headers, so including usb.h always
gives you the libusb-compat header if that package is installed.
This problem cannot be fixed with a simple -I flag because of a quirk in how
GCC's search path works:
> You can add to this list with the `-Idir` command-line option.
> All the directories named by `-I` are searched, in left-to-right
> order, before the default directories. The only exception is
> when dir is already searched by default. In this case, the
> option is ignored and the search order for system directories
> remains unchanged.
To build the MSYS2 usbview package, we resorted to copying usb.h into a local
directory and adding that directory to the search path with -I.
This patch helps to address this issue by simply changing angle-brackets to
double quotes in the two places that include usb.h (winusbio.h and usbdi.h).
This guarantees that those two include statements will work as expected.
External source code that wants to include the mingw-w64 usb.h can simply be
patched to include usbdi.h instead, which in turn includes the correct usb.h
using quotes.
Thanks!
--David Grayson
--- a/mingw-w64-headers/include/usbdi.h
+++ b/mingw-w64-headers/include/usbdi.h
@@ -20,7 +20,7 @@
#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
-#include <usb.h>
+#include "usb.h"
#include <usbioctl.h>
#define USBD_STATUS_CANCELLING ((USBD_STATUS) 0x00020000)
diff --git a/mingw-w64-headers/include/winusbio.h
b/mingw-w64-headers/include/winusbio.h
index eb4ac8f..6bde19a 100644
--- a/mingw-w64-headers/include/winusbio.h
+++ b/mingw-w64-headers/include/winusbio.h
@@ -50,7 +50,7 @@
#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
#include <windows.h>
-#include <usb.h> /* for USBD_PIPE_TYPE */
+#include "usb.h" /* for USBD_PIPE_TYPE */
#ifdef __cplusplus
extern "C" {
------------------------------------------------------------------------------
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public