From fc3eed3845183404eae34b20bfb6a5c4fd3f3da7 Mon Sep 17 00:00:00 2001 From: Ihor Dutchak Date: Mon, 13 Mar 2023 12:11:37 +0200 Subject: [PATCH] windows: Have a separate definition flag for export (#515) On some compilers an empty definition (e.g. -DHID_API_EXPORT) means the same as `=1` (i.e. -DHID_API_EXPORT=1), but the HID_API_EXPORT macro should be empty in static library build case. Having a separate compiler definition flag solves that issue. --- hidapi/hidapi.h | 15 +++++++-------- windows/CMakeLists.txt | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hidapi/hidapi.h b/hidapi/hidapi.h index ac78cb2..90cae45 100644 --- a/hidapi/hidapi.h +++ b/hidapi/hidapi.h @@ -29,18 +29,17 @@ #include +/* #480: this is to be refactored properly for v1.0 */ #ifdef _WIN32 - /* #480: this is to be refactored properly for v1.0 */ - #ifndef HID_API_EXPORT + #ifndef HID_API_NO_EXPORT_DEFINE #define HID_API_EXPORT __declspec(dllexport) #endif - #define HID_API_CALL -#else - #ifndef HID_API_EXPORT - #define HID_API_EXPORT /**< API export macro */ - #endif - #define HID_API_CALL /**< API call macro */ #endif +#ifndef HID_API_EXPORT + #define HID_API_EXPORT /**< API export macro */ +#endif +/* To be removed in v1.0 */ +#define HID_API_CALL /**< API call macro */ #define HID_API_EXPORT_CALL HID_API_EXPORT HID_API_CALL /**< API export and call macro*/ diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index d32959c..c8228bc 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -26,7 +26,7 @@ if(NOT BUILD_SHARED_LIBS) target_compile_definitions(hidapi_winapi # prevent marking functions as __declspec(dllexport) for static library build # #480: this should be refactored for v1.0 - PUBLIC HID_API_EXPORT + PUBLIC HID_API_NO_EXPORT_DEFINE ) endif()