Make it compile under MSVC2017.

This commit is contained in:
WangYi 2018-03-18 01:05:09 +08:00 committed by Unknown
parent 66d3560608
commit 82f23c411d
5 changed files with 22 additions and 8 deletions

View file

@ -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

View file

@ -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)
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

View file

@ -33,7 +33,9 @@
#ifndef __NFC_BUS_UART_H__
# define __NFC_BUS_UART_H__
#if !defined(_MSC_VER)
# include <sys/time.h>
#endif
# include <stdio.h>
# include <string.h>

View file

@ -34,7 +34,9 @@
#include <stdbool.h>
#include <err.h>
#if !defined(_MSC_VER)
# include <sys/time.h>
#endif
#include "nfc/nfc.h"

View file

@ -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