diff --git a/doc/mkdocs/docs/features/macros.md b/doc/mkdocs/docs/features/macros.md index 9994c5dcde..dabb29917b 100644 --- a/doc/mkdocs/docs/features/macros.md +++ b/doc/mkdocs/docs/features/macros.md @@ -125,6 +125,19 @@ security reasons (e.g., Intel Software Guard Extensions (SGX)). #undef JSON_NO_IO ``` +## `JSON_SKIP_LIBRARY_VERSION_CHECK` + +When defined, the library will not create a compiler warning when a different version of the library was already +included. + +!!! info "Default behavior" + + By default, the macro is not defined. + + ```cpp + #undef JSON_SKIP_LIBRARY_VERSION_CHECK + ``` + ## `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK` When defined, the library will not create a compile error when a known unsupported compiler is detected. This allows to diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 6bf77d507e..76217f01f9 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -39,6 +39,14 @@ SOFTWARE. #ifndef INCLUDE_NLOHMANN_JSON_HPP_ #define INCLUDE_NLOHMANN_JSON_HPP_ +#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK + #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH) + #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 10 || NLOHMANN_JSON_VERSION_PATCH != 5 + #warning "Already included a different version of the library!" + #endif + #endif +#endif + #define NLOHMANN_JSON_VERSION_MAJOR 3 #define NLOHMANN_JSON_VERSION_MINOR 10 #define NLOHMANN_JSON_VERSION_PATCH 5 diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index ba272a126e..66ad9091e4 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -39,6 +39,14 @@ SOFTWARE. #ifndef INCLUDE_NLOHMANN_JSON_HPP_ #define INCLUDE_NLOHMANN_JSON_HPP_ +#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK + #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH) + #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 10 || NLOHMANN_JSON_VERSION_PATCH != 5 + #warning "Already included a different version of the library!" + #endif + #endif +#endif + #define NLOHMANN_JSON_VERSION_MAJOR 3 #define NLOHMANN_JSON_VERSION_MINOR 10 #define NLOHMANN_JSON_VERSION_PATCH 5 diff --git a/third_party/amalgamate/amalgamate.py b/third_party/amalgamate/amalgamate.py index f01b43b760..0aed7c9014 100755 --- a/third_party/amalgamate/amalgamate.py +++ b/third_party/amalgamate/amalgamate.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # coding=utf-8 # amalgamate.py - Amalgamate C source and header files.