From 91ed68b4a63759c1fe8e93313cb9e4a9f9bc1fb5 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Fri, 31 Dec 2021 13:55:51 +0100 Subject: [PATCH] Fix conflicting definition of `ARDUINOJSON_DEFINE_STATIC_ARRAY()` --- extras/tests/Helpers/progmem_emulation.hpp | 2 +- src/ArduinoJson/Polyfills/static_array.hpp | 22 +++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/extras/tests/Helpers/progmem_emulation.hpp b/extras/tests/Helpers/progmem_emulation.hpp index 545cef36..7ca5f158 100644 --- a/extras/tests/Helpers/progmem_emulation.hpp +++ b/extras/tests/Helpers/progmem_emulation.hpp @@ -35,7 +35,7 @@ inline uint32_t pgm_read_dword(const void* p) { return *reinterpret_cast(convertFlashToPtr(p)); } -#define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ +#define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value) \ static type const ARDUINOJSON_CONCAT2(name, _progmem)[] = value; \ static type const* name = reinterpret_cast( \ convertPtrToFlash(ARDUINOJSON_CONCAT2(name, _progmem))); diff --git a/src/ArduinoJson/Polyfills/static_array.hpp b/src/ArduinoJson/Polyfills/static_array.hpp index b070628c..41992d6e 100644 --- a/src/ArduinoJson/Polyfills/static_array.hpp +++ b/src/ArduinoJson/Polyfills/static_array.hpp @@ -10,25 +10,21 @@ # include -# ifndef ARDUINOJSON_DEFINE_STATIC_ARRAY -# define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ +# ifndef ARDUINOJSON_DEFINE_PROGMEM_ARRAY +# define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value) \ static type const name[] PROGMEM = value; # endif -# ifndef ARDUINOJSON_READ_STATIC_ARRAY -# define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) \ - pgm_read(name + index) -# endif +# define ARDUINOJSON_DEFINE_STATIC_ARRAY ARDUINOJSON_DEFINE_PROGMEM_ARRAY + +# define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) \ + pgm_read(name + index) #else // i.e. ARDUINOJSON_ENABLE_PROGMEM == 0 -# ifndef ARDUINOJSON_DEFINE_STATIC_ARRAY -# define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ - static type const name[] = value; -# endif +# define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ + static type const name[] = value; -# ifndef ARDUINOJSON_READ_STATIC_ARRAY -# define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) name[index] -# endif +# define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) name[index] #endif