[PATCH 3/5] fix for MSVC6 preprocessor not accepting blank parameters

Pete Batard pete at akeo.ie
Mon Jan 30 17:23:12 EST 2012


Another MSVC6, with same outcome (won't compile without)

Original [PATCH 03/11] from Michael.

Regards,

/Pete

-------- Original Message --------
Subject: [Libusb-devel] [PATCH 03/11] [msvc] fix for MSVC6 preprocessor 
not accepting blank parameters
Date: Fri, 23 Dec 2011 18:46:53 -0600
From: Michael Plante <michael.plante at gmail.com>
To: libusb-devel <libusb-devel at lists.sourceforge.net>

>From c9f372e0e138f892e5665923db66a77ae431b543 Mon Sep 17 00:00:00 2001
From: Pete Batard <pete at akeo.ie>
Date: Sun, 13 Nov 2011 23:10:15 +0000
Subject: [PATCH 03/11] [msvc] fix for MSVC6 preprocessor not accepting
blank parameters

* unlike later iterations of Visual Studio, MSVC6 does not accept
   blank parameters on macro calls [eg. CALL(a, ,b)]
* blank params were used with the DLL_DECLARE and DLL_LOAD macros
* issue reported by Satz Klauer
---
  libusb/os/windows_usb.h |   46 
++++++++++++++++++++++++----------------------
  1 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h
index b629d18..e74f82d 100644
--- a/libusb/os/windows_usb.h
+++ b/libusb/os/windows_usb.h
@@ -244,31 +244,33 @@ struct driver_lookup {
  /*
   * API macros - from libusb-win32 1.x
   */
-#define DLL_DECLARE_PREFIXED(api, ret, prefix, name, args)    \
-	typedef ret (api * __dll_##name##_t)args;                 \
-	static __dll_##name##_t prefix##name = NULL
-
-#define DLL_LOAD_PREFIXED(dll, prefix, name, ret_on_failure)  \
-	do {                                                      \
-		HMODULE h = GetModuleHandleA(#dll);                   \
-	if (!h)                                                   \
-		h = LoadLibraryA(#dll);                               \
-	if (!h) {                                                 \
-		if (ret_on_failure) { return LIBUSB_ERROR_NOT_FOUND; }\
-		else { break; }                                       \
-	}                                                         \
-	prefix##name = (__dll_##name##_t)GetProcAddress(h, #name);\
-	if (prefix##name) break;                                  \
-	prefix##name = (__dll_##name##_t)GetProcAddress(h, #name "A");\
-	if (prefix##name) break;                                  \
-	prefix##name = (__dll_##name##_t)GetProcAddress(h, #name "W");\
-	if (prefix##name) break;                                  \
-	if(ret_on_failure)                                        \
-		return LIBUSB_ERROR_NOT_FOUND;                        \
+#define DLL_DECLARE_PREFIXNAME(api, ret, prefixname, name, args)    \
+	typedef ret (api * __dll_##name##_t)args;                       \
+	static __dll_##name##_t prefixname = NULL
+
+#define DLL_LOAD_PREFIXNAME(dll, prefixname, name, ret_on_failure) \
+	do {                                                           \
+		HMODULE h = GetModuleHandleA(#dll);                        \
+	if (!h)                                                        \
+		h = LoadLibraryA(#dll);                                    \
+	if (!h) {                                                      \
+		if (ret_on_failure) { return LIBUSB_ERROR_NOT_FOUND; }     \
+		else { break; }                                            \
+	}                                                              \
+	prefixname = (__dll_##name##_t)GetProcAddress(h, #name);       \
+	if (prefixname) break;                                         \
+	prefixname = (__dll_##name##_t)GetProcAddress(h, #name "A");   \
+	if (prefixname) break;                                         \
+	prefixname = (__dll_##name##_t)GetProcAddress(h, #name "W");   \
+	if (prefixname) break;                                         \
+	if(ret_on_failure)                                             \
+		return LIBUSB_ERROR_NOT_FOUND;                             \
  	} while(0)

-#define DLL_DECLARE(api, ret, name, args)   DLL_DECLARE_PREFIXED(api,
ret, , name, args)
-#define DLL_LOAD(dll, name, ret_on_failure) DLL_LOAD_PREFIXED(dll, ,
name, ret_on_failure)
+#define DLL_DECLARE(api, ret, name, args)
DLL_DECLARE_PREFIXNAME(api, ret, name, name, args)
+#define DLL_LOAD(dll, name, ret_on_failure) DLL_LOAD_PREFIXNAME(dll,
name, name, ret_on_failure)
+#define DLL_DECLARE_PREFIXED(api, ret, prefix, name, args)
DLL_DECLARE_PREFIXNAME(api, ret, prefix##name, name, args)
+#define DLL_LOAD_PREFIXED(dll, prefix, name, ret_on_failure)
DLL_LOAD_PREFIXNAME(dll, prefix##name, name, ret_on_failure)

  /* OLE32 dependency */
  DLL_DECLARE_PREFIXED(WINAPI, HRESULT, p, CLSIDFromString, (LPCOLESTR,
LPCLSID));
-- 
1.7.3.1.msysgit.0

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-msvc-fix-for-MSVC6-preprocessor-not-accepting-blank-.patch
Type: application/octet-stream
Size: 4132 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/libusbx/attachments/20120130/e5f486b3/attachment.obj>


More information about the libusbx mailing list