Skip to content

Commit fc3eed3

Browse files
authored
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.
1 parent e6caff3 commit fc3eed3

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

hidapi/hidapi.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,17 @@
2929

3030
#include <wchar.h>
3131

32+
/* #480: this is to be refactored properly for v1.0 */
3233
#ifdef _WIN32
33-
/* #480: this is to be refactored properly for v1.0 */
34-
#ifndef HID_API_EXPORT
34+
#ifndef HID_API_NO_EXPORT_DEFINE
3535
#define HID_API_EXPORT __declspec(dllexport)
3636
#endif
37-
#define HID_API_CALL
38-
#else
39-
#ifndef HID_API_EXPORT
40-
#define HID_API_EXPORT /**< API export macro */
41-
#endif
42-
#define HID_API_CALL /**< API call macro */
4337
#endif
38+
#ifndef HID_API_EXPORT
39+
#define HID_API_EXPORT /**< API export macro */
40+
#endif
41+
/* To be removed in v1.0 */
42+
#define HID_API_CALL /**< API call macro */
4443

4544
#define HID_API_EXPORT_CALL HID_API_EXPORT HID_API_CALL /**< API export and call macro*/
4645

windows/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if(NOT BUILD_SHARED_LIBS)
2626
target_compile_definitions(hidapi_winapi
2727
# prevent marking functions as __declspec(dllexport) for static library build
2828
# #480: this should be refactored for v1.0
29-
PUBLIC HID_API_EXPORT
29+
PUBLIC HID_API_NO_EXPORT_DEFINE
3030
)
3131
endif()
3232

0 commit comments

Comments
 (0)