Skip to content

Commit 917077e

Browse files
committed
Fix windows build
1 parent 4646741 commit 917077e

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

cmake/env.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
9797
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
9898
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
9999
endif()
100+
101+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS_SPACED}")
100102
endif()
101103

102104
add_compile_options("$<$<CONFIG:DEBUG>:-DDEBUG>")

cmake/msvc_warnings.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,10 @@
2929
#
3030

3131
set(WARNING_FLAGS
32+
33+
# possible loss of data
34+
/wd4244
35+
36+
# convert int to size_t
37+
/wd4267
3238
)

source/Logger.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,17 @@ namespace vx {
8080
const auto nowAsTimeT = std::chrono::system_clock::to_time_t( now );
8181
const auto nowMs = std::chrono::duration_cast<std::chrono::microseconds>( now.time_since_epoch() ) % 1000000;
8282

83+
#ifdef _WIN32
84+
localtime_s(&currentLocalTime, &nowAsTimeT);
85+
#else
86+
localtime_r(&nowAsTimeT, &currentLocalTime);
87+
#endif
88+
8389
std::ostringstream nowSs;
8490
nowSs
85-
<< std::put_time( localtime_r( &nowAsTimeT, &currentLocalTime ), "%Y-%m-%dT%T" )
91+
<< std::put_time( &currentLocalTime, "%Y-%m-%dT%T" )
8692
<< '.' << std::setfill( '0' ) << std::setw( 6 ) << nowMs.count()
87-
<< std::put_time( localtime_r( &nowAsTimeT, &currentLocalTime ), "%z" );
93+
<< std::put_time( &currentLocalTime, "%z" );
8894
std::string result = nowSs.str();
8995
/* somewhat special - maybe see systemtimeformatter */
9096
result.replace( result.end() - 2, result.end() - 2, ":" );

0 commit comments

Comments
 (0)