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.
This commit is contained in:
Jef Driesen 2020-08-21 16:45:51 +02:00
parent 51b1ae925c
commit 7a4c5e919f
6 changed files with 7 additions and 0 deletions

View File

@ -29,6 +29,7 @@
#include <string.h>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define NOGDI
#include <windows.h>
#endif

View File

@ -21,6 +21,7 @@
#include <stdlib.h>
#define WIN32_LEAN_AND_MEAN
#define NOGDI
#include <windows.h>

View File

@ -23,6 +23,7 @@
#define DC_SOCKET_H
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define NOGDI
#include <winsock2.h>
#include <windows.h>

View File

@ -26,6 +26,7 @@
#include <stdlib.h>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define NOGDI
#include <windows.h>
#else

View File

@ -28,6 +28,7 @@
#ifdef HAVE_LIBUSB
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define NOGDI
#endif
#include <libusb.h>

View File

@ -29,6 +29,7 @@
#include <pthread.h>
#endif
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define NOGDI
#include <windows.h>
#endif
@ -43,6 +44,7 @@
#if defined(USE_LIBUSB)
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define NOGDI
#endif
#include <libusb.h>