Skip to content

Commit

Permalink
fixed(getCompilerInfo): fixed visual studio __cplusplus always 199711…
Browse files Browse the repository at this point in the history
…L problem
  • Loading branch information
itas109 committed Apr 17, 2024
1 parent f1bf6c1 commit 9caf4a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/CSerialPort/itimer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef __I_TIMER_HPP__
#define __I_TIMER_HPP__

#if __cplusplus >= 201103L
#if __cplusplus >= 201103L || _MSVC_LANG >= 201103L
// C++11 support: msvc2013 gcc4.8.5 clang3.0 etc.
#define CPP11_TIMER
#endif
Expand Down
9 changes: 8 additions & 1 deletion include/CSerialPort/iutils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class IUtils
char compilerVersion[10];
compilerVersion[0] = '\0';
int bit = (8 == sizeof(char *)) ? 64 : 32;
long cppStdVersion = 0;

// https://sourceforge.net/p/predef/wiki/Home/
#if defined(__x86_64__) /*GNU C*/ || defined(_M_AMD64) /*Visual Studio*/
Expand Down Expand Up @@ -287,7 +288,13 @@ class IUtils
strFormat(compilerVersion, 10, "%d.%d.%d", 0, 0, 0);
#endif

strFormat(info, len, "OS: %s, Arch: %s, Compiler: %s(%s), Bit: %d, C++: %ld", osName, archName, compilerName, compilerVersion, bit, __cplusplus);
#if defined(_MSVC_LANG)
cppStdVersion = _MSVC_LANG;
#else
cppStdVersion = __cplusplus;
#endif

strFormat(info, len, "OS: %s, Arch: %s, Compiler: %s(%s), Bit: %d, C++: %ldL", osName, archName, compilerName, compilerVersion, bit, cppStdVersion);

return info;
}
Expand Down

0 comments on commit 9caf4a5

Please sign in to comment.