From 7a4c5e919fe291d644d83293a0bd2058cf77addb Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 21 Aug 2020 16:45:51 +0200 Subject: [PATCH] Fix a conflict with the Windows header files In one of the Windows system header files, an "interface" macro is defined as: #define interface struct This results in some very strange build errors when also including the descriptor-private.h header file. That's because the dc_usb_params_t struct has a member field named "interface": typedef struct dc_usb_params_t { unsigned int interface; unsigned char endpoint_in; unsigned char endpoint_out; } dc_usb_params_t; As a workaround, define the WIN32_LEAN_AND_MEAN macro before including the windows.h header file. This excludes some less common Windows API declarations, including the above one. --- src/context.c | 1 + src/serial_win32.c | 1 + src/socket.h | 1 + src/timer.c | 1 + src/usb.c | 1 + src/usbhid.c | 2 ++ 6 files changed, 7 insertions(+) diff --git a/src/context.c b/src/context.c index 63824a5..c7642e6 100644 --- a/src/context.c +++ b/src/context.c @@ -29,6 +29,7 @@ #include #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN #define NOGDI #include #endif diff --git a/src/serial_win32.c b/src/serial_win32.c index 8427a25..2b009f0 100644 --- a/src/serial_win32.c +++ b/src/serial_win32.c @@ -21,6 +21,7 @@ #include +#define WIN32_LEAN_AND_MEAN #define NOGDI #include diff --git a/src/socket.h b/src/socket.h index e2efa14..bc37095 100644 --- a/src/socket.h +++ b/src/socket.h @@ -23,6 +23,7 @@ #define DC_SOCKET_H #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN #define NOGDI #include #include diff --git a/src/timer.c b/src/timer.c index 14ccd46..cc17f23 100644 --- a/src/timer.c +++ b/src/timer.c @@ -26,6 +26,7 @@ #include #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN #define NOGDI #include #else diff --git a/src/usb.c b/src/usb.c index e39bc48..758c604 100644 --- a/src/usb.c +++ b/src/usb.c @@ -28,6 +28,7 @@ #ifdef HAVE_LIBUSB #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN #define NOGDI #endif #include diff --git a/src/usbhid.c b/src/usbhid.c index 22981b7..9231e64 100644 --- a/src/usbhid.c +++ b/src/usbhid.c @@ -29,6 +29,7 @@ #include #endif #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN #define NOGDI #include #endif @@ -43,6 +44,7 @@ #if defined(USE_LIBUSB) #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN #define NOGDI #endif #include