diff options
author | Pete Batard <pete@akeo.ie> | 2011-11-13 23:10:15 +0000 |
---|---|---|
committer | Peter Stuge <peter@stuge.se> | 2012-02-08 14:46:10 +0100 |
commit | 17ad642cae618cc09c5516612fa3880d4b6b8635 (patch) | |
tree | 60353c2ca1cfeec6e7729835ab2c0483d6e81fc3 | |
parent | c591a7cbf7dbc6fbb4368e65cf58a8cd02582aeb (diff) | |
download | libusb-17ad642cae618cc09c5516612fa3880d4b6b8635.tar.gz |
Windows: 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 Elmi
-rw-r--r-- | libusb/os/windows_usb.h | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h index b629d18..4fe4916 100644 --- a/libusb/os/windows_usb.h +++ b/libusb/os/windows_usb.h @@ -244,11 +244,11 @@ struct driver_lookup { /* * API macros - from libusb-win32 1.x */ -#define DLL_DECLARE_PREFIXED(api, ret, prefix, name, args) \ +#define DLL_DECLARE_PREFIXNAME(api, ret, prefixname, name, args) \ typedef ret (api * __dll_##name##_t)args; \ - static __dll_##name##_t prefix##name = NULL + static __dll_##name##_t prefixname = NULL -#define DLL_LOAD_PREFIXED(dll, prefix, name, ret_on_failure) \ +#define DLL_LOAD_PREFIXNAME(dll, prefixname, name, ret_on_failure) \ do { \ HMODULE h = GetModuleHandleA(#dll); \ if (!h) \ @@ -257,18 +257,20 @@ struct driver_lookup { 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; \ + 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)); |