diff --git a/contrib/windows.h b/contrib/windows.h index 88817db..e443d09 100644 --- a/contrib/windows.h +++ b/contrib/windows.h @@ -48,7 +48,9 @@ # define ENOTSUP WSAEOPNOTSUPP # define ECONNABORTED WSAECONNABORTED # else +#if !defined(_MSC_VER) || (_MSC_VER < 1910) // VS2017 don't like snprintf macro # define snprintf sprintf_s +#endif # define strdup _strdup # endif diff --git a/libnfc/CMakeLists.txt b/libnfc/CMakeLists.txt index 514f60d..856c46e 100644 --- a/libnfc/CMakeLists.txt +++ b/libnfc/CMakeLists.txt @@ -5,6 +5,9 @@ IF(WIN32) # Add in the rc for version information in the dll LIST(APPEND WINDOWS_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/../windows/libnfc.rc) + IF (NOT MINGW) + LIST(APPEND WINDOWS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/nfc_msvc.def) + ENDIF() ENDIF(WIN32) # Library's chips @@ -88,13 +91,16 @@ SET_TARGET_PROPERTIES(nfc PROPERTIES SOVERSION 6 VERSION 6.0.0) IF(WIN32) # Libraries that are windows specific TARGET_LINK_LIBRARIES(nfc wsock32) - - ADD_CUSTOM_COMMAND( - OUTPUT libnfc.lib - COMMAND ${DLLTOOL} -d ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/nfc.def -l ${CMAKE_CURRENT_BINARY_DIR}/libnfc.lib ${CMAKE_CURRENT_BINARY_DIR}/libnfc.dll - DEPENDS nfc ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/nfc.def - ) - ADD_CUSTOM_TARGET(win32lib ALL DEPENDS libnfc.lib) + IF(MINGW) + ADD_CUSTOM_COMMAND( + OUTPUT libnfc.lib + COMMAND ${DLLTOOL} -d ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/nfc.def -l ${CMAKE_CURRENT_BINARY_DIR}/libnfc.lib ${CMAKE_CURRENT_BINARY_DIR}/libnfc.dll + DEPENDS nfc ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/nfc.def + ) + ADD_CUSTOM_TARGET(win32lib ALL DEPENDS libnfc.lib) + ELSE() + ADD_LIBRARY(win32lib ALIAS nfc) + ENDIF() # On Windows the shared (runtime) library should be either in the same # directory as the excutables or in the path, we add it to same directory diff --git a/libnfc/buses/uart.h b/libnfc/buses/uart.h index 49b822a..39d8d2f 100644 --- a/libnfc/buses/uart.h +++ b/libnfc/buses/uart.h @@ -33,7 +33,9 @@ #ifndef __NFC_BUS_UART_H__ # define __NFC_BUS_UART_H__ +#if !defined(_MSC_VER) # include +#endif # include # include diff --git a/libnfc/nfc-internal.h b/libnfc/nfc-internal.h index 4fa2fc2..e9015ff 100644 --- a/libnfc/nfc-internal.h +++ b/libnfc/nfc-internal.h @@ -34,7 +34,9 @@ #include #include +#if !defined(_MSC_VER) # include +#endif #include "nfc/nfc.h" diff --git a/libnfc/nfc.c b/libnfc/nfc.c index 2d56bf6..0f9e287 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -565,7 +565,7 @@ nfc_initiator_select_passive_target(nfc_device *pnd, nfc_target *pnt) { uint8_t *abtInit = NULL; - uint8_t abtTmpInit[MAX(12, szInitData)]; + uint8_t *abtTmpInit = malloc(MAX(12, szInitData)); size_t szInit = 0; int res; if ((res = nfc_device_validate_modulation(pnd, N_INITIATOR, &nm)) != NFC_SUCCESS) @@ -583,6 +583,8 @@ nfc_initiator_select_passive_target(nfc_device *pnd, } HAL(initiator_select_passive_target, pnd, nm, abtInit, szInit, pnt); + + free(abtTmpInit); } /** @ingroup initiator