Set ARDUINOJSON_USE_DOUBLE to 0 by default on 8-bit architectures

This commit is contained in:
Benoit Blanchon
2024-08-27 14:53:28 +02:00
parent 7643dadaec
commit 0278e94fce
3 changed files with 12 additions and 7 deletions

View File

@ -8,6 +8,7 @@ HEAD
* Store 64-bit numbers (`double` and `long long`) in an additional slot * Store 64-bit numbers (`double` and `long long`) in an additional slot
* Reduce the slot size (see table below) * Reduce the slot size (see table below)
* Improve message when user forgets third arg of `serializeJson()` et al. * Improve message when user forgets third arg of `serializeJson()` et al.
* Set `ARDUINOJSON_USE_DOUBLE` to `0` by default on 8-bit architectures
| Architecture | before | after | | Architecture | before | after |
|--------------|----------|----------| |--------------|----------|----------|

View File

@ -8,7 +8,7 @@ static_assert(ARDUINOJSON_SLOT_ID_SIZE == 1, "ARDUINOJSON_SLOT_ID_SIZE");
static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN"); static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); static_assert(ARDUINOJSON_USE_DOUBLE == 0, "ARDUINOJSON_USE_DOUBLE");
static_assert(sizeof(ArduinoJson::detail::VariantData) == 6, static_assert(sizeof(ArduinoJson::detail::VariantData) == 6,
"sizeof(VariantData)"); "sizeof(VariantData)");

View File

@ -56,12 +56,6 @@
# endif # endif
#endif #endif
// Store floating-point values with float (0) or double (1)
// https://arduinojson.org/v7/config/use_double/
#ifndef ARDUINOJSON_USE_DOUBLE
# define ARDUINOJSON_USE_DOUBLE 1
#endif
// Pointer size: a heuristic to set sensible defaults // Pointer size: a heuristic to set sensible defaults
#ifndef ARDUINOJSON_SIZEOF_POINTER #ifndef ARDUINOJSON_SIZEOF_POINTER
# if defined(__SIZEOF_POINTER__) # if defined(__SIZEOF_POINTER__)
@ -73,6 +67,16 @@
# endif # endif
#endif #endif
// Store floating-point values with float (0) or double (1)
// https://arduinojson.org/v7/config/use_double/
#ifndef ARDUINOJSON_USE_DOUBLE
# if ARDUINOJSON_SIZEOF_POINTER >= 4 // 32 & 64 bits systems
# define ARDUINOJSON_USE_DOUBLE 1
# else
# define ARDUINOJSON_USE_DOUBLE 0
# endif
#endif
// Store integral values with long (0) or long long (1) // Store integral values with long (0) or long long (1)
// https://arduinojson.org/v7/config/use_long_long/ // https://arduinojson.org/v7/config/use_long_long/
#ifndef ARDUINOJSON_USE_LONG_LONG #ifndef ARDUINOJSON_USE_LONG_LONG