From 2dd94af2ea102f201ca3507101397adf44b95b8e Mon Sep 17 00:00:00 2001 From: Jonas Malaco Date: Fri, 7 Feb 2020 19:14:34 -0300 Subject: [PATCH] Move local variable declaration to the beginning of the function Older versions of MSVC (for example when using Visual Studio 10) don't yet support variable declaration in the middle of blocks: hidapi\windows\hid.c(845) : error C2275: 'BOOL' : illegal use of this type as an expression C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\windef.h(153) : see declaration of 'BOOL' Move the declaration of res to the beginning of the function. Like in hid_get_feature_report, only res is moved, essentially ignoring the #if 0 block (or assuming it will never be enabled). --- windows/hid.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/windows/hid.c b/windows/hid.c index f201a51..799b355 100755 --- a/windows/hid.c +++ b/windows/hid.c @@ -828,8 +828,8 @@ int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *dev, unsigned int HID_API_EXPORT HID_API_CALL hid_get_input_report(hid_device *dev, unsigned char *data, size_t length) { -#if 0 BOOL res; +#if 0 res = HidD_GetInputReport(dev->device_handle, data, length); if (!res) { register_error(dev, "HidD_GetInputReport"); @@ -842,7 +842,7 @@ int HID_API_EXPORT HID_API_CALL hid_get_input_report(hid_device *dev, unsigned c OVERLAPPED ol; memset(&ol, 0, sizeof(ol)); - BOOL res = DeviceIoControl(dev->device_handle, + res = DeviceIoControl(dev->device_handle, IOCTL_HID_GET_INPUT_REPORT, data, length, data, length,