Skip to content

Commit

Permalink
Auto enable std::string and stream on modern compilers (closes bblanc…
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed Jan 4, 2020
1 parent ab2193d commit f2f856e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ HEAD

* Added `BasicJsonDocument::shrinkToFit()`
* Added support of `uint8_t` for `serializeJson()`, `serializeJsonPretty()`, and `serializeMsgPack()` (issue #1142)
* Auto enable support for `std::string` and `std::stream` on modern compilers (issue #1156)
No need to define `ARDUINOJSON_ENABLE_STD_STRING` and `ARDUINOJSON_ENABLE_STD_STREAM`.

v6.13.0 (2019-11-01)
-------
Expand Down
23 changes: 23 additions & 0 deletions src/ArduinoJson/Configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,29 @@
#endif
#endif

// Auto enable std::stream if the right headers are here and no conflicting
// macro is defined
#if !defined(ARDUINOJSON_ENABLE_STD_STREAM) && defined(__has_include)
#if __has_include(<istream>) && \
__has_include(<ostream>) && \
!defined(min) && \
!defined(max)
#define ARDUINOJSON_ENABLE_STD_STREAM 1
#else
#define ARDUINOJSON_ENABLE_STD_STREAM 0
#endif
#endif

// Auto enable std::string if the right header is here and no conflicting
// macro is defined
#if !defined(ARDUINOJSON_ENABLE_STD_STRING) && defined(__has_include)
#if __has_include(<string>) && !defined(min) && !defined(max)
#define ARDUINOJSON_ENABLE_STD_STRING 1
#else
#define ARDUINOJSON_ENABLE_STD_STRING 0
#endif
#endif

#if ARDUINOJSON_EMBEDDED_MODE

// Store floats by default to reduce the memory usage (issue #134)
Expand Down

0 comments on commit f2f856e

Please sign in to comment.