未验证 提交 b40fc45f 编写于 作者: H huzhiqiang 提交者: GitHub

[windows] Fix windows compiling error (#4417)

上级 05f36e42
...@@ -27,7 +27,7 @@ SET(FLATBUFFERS_SOURCES_DIR ${CMAKE_SOURCE_DIR}/third-party/flatbuffers) ...@@ -27,7 +27,7 @@ SET(FLATBUFFERS_SOURCES_DIR ${CMAKE_SOURCE_DIR}/third-party/flatbuffers)
SET(FLATBUFFERS_INSTALL_DIR ${THIRD_PARTY_PATH}/install/flatbuffers) SET(FLATBUFFERS_INSTALL_DIR ${THIRD_PARTY_PATH}/install/flatbuffers)
SET(FLATBUFFERS_INCLUDE_DIR "${FLATBUFFERS_SOURCES_DIR}/include" CACHE PATH "flatbuffers include directory." FORCE) SET(FLATBUFFERS_INCLUDE_DIR "${FLATBUFFERS_SOURCES_DIR}/include" CACHE PATH "flatbuffers include directory." FORCE)
IF(WIN32) IF(WIN32)
set(FLATBUFFERS_LIBRARIES "${FLATBUFFERS_INSTALL_DIR}/${LIBDIR}/libflatbuffers.lib" CACHE FILEPATH "FLATBUFFERS_LIBRARIES" FORCE) set(FLATBUFFERS_LIBRARIES "${FLATBUFFERS_INSTALL_DIR}/${LIBDIR}/flatbuffers.lib" CACHE FILEPATH "FLATBUFFERS_LIBRARIES" FORCE)
ELSE(WIN32) ELSE(WIN32)
set(FLATBUFFERS_LIBRARIES "${FLATBUFFERS_INSTALL_DIR}/${LIBDIR}/libflatbuffers.a" CACHE FILEPATH "FLATBUFFERS_LIBRARIES" FORCE) set(FLATBUFFERS_LIBRARIES "${FLATBUFFERS_INSTALL_DIR}/${LIBDIR}/libflatbuffers.a" CACHE FILEPATH "FLATBUFFERS_LIBRARIES" FORCE)
ENDIF(WIN32) ENDIF(WIN32)
...@@ -64,13 +64,6 @@ ExternalProject_Add( ...@@ -64,13 +64,6 @@ ExternalProject_Add(
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE} -DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
) )
IF(WIN32)
IF(NOT EXISTS "${FLATBUFFERS_INSTALL_DIR}/${LIBDIR}/libflatbuffers.lib")
add_custom_command(TARGET extern_flatbuffers POST_BUILD
COMMAND cmake -E copy ${FLATBUFFERS_INSTALL_DIR}/${LIBDIR}/flatbuffers_static.lib ${FLATBUFFERS_INSTALL_DIR}/${LIBDIR}/libflatbuffers.lib
)
ENDIF()
ENDIF(WIN32)
ADD_LIBRARY(flatbuffers STATIC IMPORTED GLOBAL) ADD_LIBRARY(flatbuffers STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET flatbuffers PROPERTY IMPORTED_LOCATION ${FLATBUFFERS_LIBRARIES}) SET_PROPERTY(TARGET flatbuffers PROPERTY IMPORTED_LOCATION ${FLATBUFFERS_LIBRARIES})
ADD_DEPENDENCIES(flatbuffers extern_flatbuffers) ADD_DEPENDENCIES(flatbuffers extern_flatbuffers)
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <sys/types.h> #include <sys/types.h>
#elif defined(_WIN32) #elif defined(_WIN32)
#define NOMINMAX // msvc max/min macro conflict with std::min/max #define NOMINMAX // msvc max/min macro conflict with std::min/max
#define GLOG_NO_ABBREVIATED_SEVERITIES
#include <windows.h> #include <windows.h>
#else #else
#include <unistd.h> #include <unistd.h>
......
...@@ -156,10 +156,11 @@ from_chars_result aton_unsigned(const char* str, ...@@ -156,10 +156,11 @@ from_chars_result aton_unsigned(const char* str,
} }
val += cv; val += cv;
} }
if (UNLIKELY(i > std::numeric_limits<T>::digits10 + 1 || if (UNLIKELY(
i > std::numeric_limits<T>::digits10 + 1 ||
(i > std::numeric_limits<T>::digits10 && (i > std::numeric_limits<T>::digits10 &&
val > static_cast<uint64_t>(std::numeric_limits<T>::max())))) { val > static_cast<uint64_t>((std::numeric_limits<T>::max)())))) {
value = static_cast<T>(std::numeric_limits<T>::max()); value = static_cast<T>((std::numeric_limits<T>::max)());
result.ec = std::errc::result_out_of_range; result.ec = std::errc::result_out_of_range;
return result; return result;
} }
...@@ -209,10 +210,11 @@ from_chars_result aton_signed(const char* str, ...@@ -209,10 +210,11 @@ from_chars_result aton_signed(const char* str,
val += cv; val += cv;
} }
if (LIKELY(!negative)) { if (LIKELY(!negative)) {
if (UNLIKELY(i > std::numeric_limits<T>::digits10 + 1 || if (UNLIKELY(
i > std::numeric_limits<T>::digits10 + 1 ||
(i > std::numeric_limits<T>::digits10 && (i > std::numeric_limits<T>::digits10 &&
val > static_cast<int64_t>(std::numeric_limits<T>::max())))) { val > static_cast<int64_t>((std::numeric_limits<T>::max)())))) {
value = static_cast<T>(std::numeric_limits<T>::max()); value = static_cast<T>((std::numeric_limits<T>::max)());
result.ec = std::errc::result_out_of_range; result.ec = std::errc::result_out_of_range;
return result; return result;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册