From 43ec683566a69cdeb9eff79680ab612b90bc0583 Mon Sep 17 00:00:00 2001 From: Helmut Tschemernjak Date: Thu, 16 Nov 2017 09:35:40 +0100 Subject: [PATCH 1/5] Added c++ linker command to allow to include libstdc++ when linking. This is needed otherwise the template C++ container support are missing. The "compiler.c.elf.cmd" specifies the linker, the C linker was wrong here and does not work for true C++ apps. This change does not hurt because when no libstdc++ features are being used there is no change. Changed the Arduino function map() into Arduino_map(). This is needed otherwise it clashes with the C++ template class. e.g.: #include --- cores/esp32/Arduino.h | 2 +- cores/esp32/WMath.cpp | 2 +- platform.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cores/esp32/Arduino.h b/cores/esp32/Arduino.h index d60d3fe0828..98b929d634e 100644 --- a/cores/esp32/Arduino.h +++ b/cores/esp32/Arduino.h @@ -127,7 +127,7 @@ void loop(void); long random(long, long); void randomSeed(unsigned long); -long map(long, long, long, long, long); +long Arduino_map(long, long, long, long, long); #ifdef __cplusplus extern "C" { diff --git a/cores/esp32/WMath.cpp b/cores/esp32/WMath.cpp index b1099b67e66..8b0d9c37a95 100644 --- a/cores/esp32/WMath.cpp +++ b/cores/esp32/WMath.cpp @@ -52,7 +52,7 @@ long random(long howsmall, long howbig) return random(diff) + howsmall; } -long map(long x, long in_min, long in_max, long out_min, long out_max) +long Arduino_map(long x, long in_min, long in_max, long out_min, long out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } diff --git a/platform.txt b/platform.txt index ae0cbc25166..d069f6d3c0a 100644 --- a/platform.txt +++ b/platform.txt @@ -33,7 +33,7 @@ compiler.cpp.flags=-std=gnu++11 -fno-exceptions -Os -g3 -Wpointer-arith -ffuncti compiler.S.cmd=xtensa-esp32-elf-gcc compiler.S.flags=-c -g3 -x assembler-with-cpp -MMD -mlongcalls -compiler.c.elf.cmd=xtensa-esp32-elf-gcc +compiler.c.elf.cmd=xtensa-esp32-elf-g++ compiler.c.elf.flags=-nostdlib "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T esp32.peripherals.ld -T esp32.rom.spiram_incompatible_fns.ld -u ld_include_panic_highint_hdl -u call_user_start_cpu0 -Wl,--gc-sections -Wl,-static -Wl,--undefined=uxTopUsedPriority -u __cxa_guard_dummy compiler.c.elf.libs=-lgcc -lcxx -lstdc++ -lapp_trace -lapp_update -lbootloader_support -lbt -lbtdm_app -lc -lc_nano -lcoap -lcoexist -lconsole -lcore -ldriver -lesp32 -lesp_adc_cal -lespnow -lethernet -lexpat -lfatfs -lfreertos -lhal -lheap -ljsmn -ljson -llog -llwip -lm -lmbedtls -lmdns -lmicro-ecc -lnet80211 -lnewlib -lnghttp -lnvs_flash -lopenssl -lphy -lpp -lpthread -lrtc -lsdmmc -lsmartconfig -lsoc -lspi_flash -lspiffs -ltcpip_adapter -lulp -lvfs -lwear_levelling -lwpa -lwpa2 -lwpa_supplicant -lwps -lxtensa-debug-module From dd8914b52c21f6baff249a555e3524e42aa00ecd Mon Sep 17 00:00:00 2001 From: Helmut Tschemernjak Date: Thu, 16 Nov 2017 14:59:55 +0100 Subject: [PATCH 2/5] Added old map define which allows old code to compile and C++ code needs to do a #undef map before including It is now the same as in the SAMD Version --- cores/esp32/Arduino.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cores/esp32/Arduino.h b/cores/esp32/Arduino.h index 98b929d634e..5c03946098e 100644 --- a/cores/esp32/Arduino.h +++ b/cores/esp32/Arduino.h @@ -128,6 +128,7 @@ void loop(void); long random(long, long); void randomSeed(unsigned long); long Arduino_map(long, long, long, long, long); +#define map Arduino_map #ifdef __cplusplus extern "C" { From 1ab7de34ae06f76245a5b290297b382d43d7fe5a Mon Sep 17 00:00:00 2001 From: Helmut Tschemernjak Date: Thu, 16 Nov 2017 17:27:59 +0100 Subject: [PATCH 3/5] Added parameters to the map re-define --- cores/esp32/Arduino.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/Arduino.h b/cores/esp32/Arduino.h index 5c03946098e..1caad42be5b 100644 --- a/cores/esp32/Arduino.h +++ b/cores/esp32/Arduino.h @@ -128,7 +128,7 @@ void loop(void); long random(long, long); void randomSeed(unsigned long); long Arduino_map(long, long, long, long, long); -#define map Arduino_map +#define map(a,b,c,d,e) Arduino_map(a,b,c,d,e) #ifdef __cplusplus extern "C" { From 76d4ef818ae1e7bfa621fec301f64ae628280cd7 Mon Sep 17 00:00:00 2001 From: Helmut Tschemernjak Date: Mon, 27 Nov 2017 17:02:13 +0100 Subject: [PATCH 4/5] Removed parameters to avoid build errors --- cores/esp32/Arduino.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/Arduino.h b/cores/esp32/Arduino.h index 1caad42be5b..5c03946098e 100644 --- a/cores/esp32/Arduino.h +++ b/cores/esp32/Arduino.h @@ -128,7 +128,7 @@ void loop(void); long random(long, long); void randomSeed(unsigned long); long Arduino_map(long, long, long, long, long); -#define map(a,b,c,d,e) Arduino_map(a,b,c,d,e) +#define map Arduino_map #ifdef __cplusplus extern "C" { From c9f3da579ec69235672b1684f79ccb673a04a341 Mon Sep 17 00:00:00 2001 From: Helmut Tschemernjak Date: Tue, 28 Nov 2017 12:58:08 +0100 Subject: [PATCH 5/5] The renaming of map is not needed for the C++ map by using std::map --- cores/esp32/Arduino.h | 3 +-- cores/esp32/WMath.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cores/esp32/Arduino.h b/cores/esp32/Arduino.h index 5c03946098e..d60d3fe0828 100644 --- a/cores/esp32/Arduino.h +++ b/cores/esp32/Arduino.h @@ -127,8 +127,7 @@ void loop(void); long random(long, long); void randomSeed(unsigned long); -long Arduino_map(long, long, long, long, long); -#define map Arduino_map +long map(long, long, long, long, long); #ifdef __cplusplus extern "C" { diff --git a/cores/esp32/WMath.cpp b/cores/esp32/WMath.cpp index 8b0d9c37a95..b1099b67e66 100644 --- a/cores/esp32/WMath.cpp +++ b/cores/esp32/WMath.cpp @@ -52,7 +52,7 @@ long random(long howsmall, long howbig) return random(diff) + howsmall; } -long Arduino_map(long x, long in_min, long in_max, long out_min, long out_max) +long map(long x, long in_min, long in_max, long out_min, long out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; }