From 959b1d9e4cf2fcaf193f3b8151c3e23a79bd59fe Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Tue, 28 Apr 2020 09:11:46 +0200 Subject: [PATCH] Fixed error C2766 with flag `/Zc:__cplusplus` on VS2017+ (fixes #1250) --- CHANGELOG.md | 1 + extras/tests/CMakeLists.txt | 6 ++++++ src/ArduinoJson/Configuration.hpp | 12 ++++++------ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2048a8b2..9ebcdcf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ HEAD * CMake: don't build tests when imported in another project * CMake: made project arch-independent +* Visual Studio: fixed error C2766 with flag `/Zc:__cplusplus` (issue #1250) v6.15.1 (2020-04-08) ------- diff --git a/extras/tests/CMakeLists.txt b/extras/tests/CMakeLists.txt index 8d63304d..52474796 100644 --- a/extras/tests/CMakeLists.txt +++ b/extras/tests/CMakeLists.txt @@ -70,6 +70,12 @@ if(MSVC) /W4 # Set warning level /WX # Treats all compiler warnings as errors. ) + + if (NOT MSVC_VERSION LESS 1910) # >= Visual Studio 2017 + add_compile_options( + /Zc:__cplusplus # Enable updated __cplusplus macro + ) + endif() endif() include_directories(Helpers) diff --git a/src/ArduinoJson/Configuration.hpp b/src/ArduinoJson/Configuration.hpp index 839d6f7e..a73a2c5d 100644 --- a/src/ArduinoJson/Configuration.hpp +++ b/src/ArduinoJson/Configuration.hpp @@ -4,12 +4,6 @@ #pragma once -#if defined(_MSC_VER) -#define ARDUINOJSON_HAS_INT64 1 -#else -#define ARDUINOJSON_HAS_INT64 0 -#endif - #if __cplusplus >= 201103L #define ARDUINOJSON_HAS_LONG_LONG 1 #define ARDUINOJSON_HAS_NULLPTR 1 @@ -20,6 +14,12 @@ #define ARDUINOJSON_HAS_RVALUE_REFERENCES 0 #endif +#if defined(_MSC_VER) && !ARDUINOJSON_HAS_LONG_LONG +#define ARDUINOJSON_HAS_INT64 1 +#else +#define ARDUINOJSON_HAS_INT64 0 +#endif + // Small or big machine? #ifndef ARDUINOJSON_EMBEDDED_MODE #if defined(ARDUINO) /* Arduino*/ \