summaryrefslogtreecommitdiff
path: root/libusb/os/windows_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'libusb/os/windows_common.h')
-rw-r--r--libusb/os/windows_common.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/libusb/os/windows_common.h b/libusb/os/windows_common.h
index 069b147..93ea23e 100644
--- a/libusb/os/windows_common.h
+++ b/libusb/os/windows_common.h
@@ -30,6 +30,23 @@
#include <stdbool.h>
+/*
+ * Workaround for the mess that exists with the DWORD and ULONG types.
+ * Visual Studio unconditionally defines these types as 'unsigned long'
+ * and a long is always 32-bits, even on 64-bit builds. GCC on the other
+ * hand varies the width of a long, matching it to the build. To make
+ * matters worse, the platform headers for these GCC builds define a
+ * DWORD/ULONG to be 'unsigned long' on 32-bit builds and 'unsigned int'
+ * on 64-bit builds. This creates a great deal of warnings for compilers
+ * that support printf format checking since it will never actually be
+ * an unsigned long.
+ */
+#if defined(_MSC_VER)
+#define ULONG_CAST(x) (x)
+#else
+#define ULONG_CAST(x) ((unsigned long)(x))
+#endif
+
#if defined(__CYGWIN__ )
#define _stricmp strcasecmp
#define _strdup strdup