Skip to content

Commit 2f884f9

Browse files
committed
Fix preprocessors and visual studio 2017 build
1 parent 88e1cae commit 2f884f9

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

3rdparty/source_location.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace nostd {
99
struct source_location {
1010
public:
11-
#ifdef WIN32
11+
#ifdef _MSC_VER
1212
static constexpr source_location current(const char* fileName = "unsupported",
1313
const char* functionName = "unsupported",
1414
const uint_least32_t lineNumber = 0,

source/FileLogger.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ namespace vx {
124124
output.append( timestamp() );
125125

126126
std::string severity( magic_enum::enum_name( _severity ) );
127+
/* Visual Studio 2017 does not handle toupper in std namespace */
128+
#if defined _MSC_VER && _MSC_VER < 1920
129+
std::transform( std::begin( severity ), std::end( severity ), std::begin( severity ), []( auto c ) { return ::toupper( c ); } );
130+
#else
127131
std::transform( std::begin( severity ), std::end( severity ), std::begin( severity ), []( auto c ) { return std::toupper( c ); } );
132+
#endif
128133
output.append( " [" + severity + "] " );
129134
if ( std::string( _location.file_name() ) != "unsupported" ) {
130135

source/Logger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ namespace vx {
9393
const auto nowAsTimeT = std::chrono::system_clock::to_time_t( now );
9494
const auto nowMs = std::chrono::duration_cast<std::chrono::microseconds>( now.time_since_epoch() ) % 1000000;
9595

96-
#ifdef _WIN32
96+
#ifdef _MSC_VER
9797
localtime_s( &currentLocalTime, &nowAsTimeT );
9898
#else
9999
localtime_r( &nowAsTimeT, &currentLocalTime );

source/StdLogger.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ namespace vx {
6565
output.append( timestamp() );
6666

6767
std::string severity( magic_enum::enum_name( _severity ) );
68+
/* Visual Studio 2017 does not handle toupper in std namespace */
69+
#if defined _MSC_VER && _MSC_VER < 1920
70+
std::transform( std::begin( severity ), std::end( severity ), std::begin( severity ), []( auto c ) { return ::toupper( c ); } );
71+
#else
6872
std::transform( std::begin( severity ), std::end( severity ), std::begin( severity ), []( auto c ) { return std::toupper( c ); } );
73+
#endif
6974
if ( m_useColor ) {
7075

7176
switch ( _severity ) {

source/XmlFileLogger.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ namespace vx {
7676
}
7777

7878
std::string severity( magic_enum::enum_name( _severity ) );
79+
/* Visual Studio 2017 does not handle toupper in std namespace */
80+
#if defined _MSC_VER && _MSC_VER < 1920
81+
std::transform( std::begin( severity ), std::end( severity ), std::begin( severity ), []( auto c ) { return ::toupper( c ); } );
82+
#else
7983
std::transform( std::begin( severity ), std::end( severity ), std::begin( severity ), []( auto c ) { return std::toupper( c ); } );
84+
#endif
8085
output.append( "<severity>" );
8186
output.append( severity );
8287
output.append( "</severity>" );

0 commit comments

Comments
 (0)