I also work with C++, which worked fine for me so far. Until recently I wasn't using any new features of C++11 (which the compiler is capable of I think). But I tried to do this:
Code: Select all
int32_t ICACHE_FLASH_ATTR Util::get_lowest_value(int32_t *values) {
return Util::get_value_with_compare(values, [](int32_t v1, int32_t v2) -> bool { return v1 < v2; });
}
int32_t ICACHE_FLASH_ATTR Util::get_highest_value(int32_t *values) {
return Util::get_value_with_compare(values, [](int32_t v1, int32_t v2) -> bool { return v1 > v2; });
}
int32_t ICACHE_FLASH_ATTR Util::get_value_with_compare(int32_t *values, std::function<bool (int32_t, int32_t)> compare) {
int32_t value = values[0];
for(uint16_t i = 1; i < sizeof(values); i++) {
if(compare(values[i], value))
value = values[i];
}
return value;
}
It compiles fine (this is an example for how the compiler is called for one of my classes:
Code: Select all
xtensa-lx106-elf-g++ -Os -std=c++11 -g -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -fno-builtin-printf -DICACHE_FLASH -DGLOBAL_DEBUG_ON -DSPI_FLASH_SIZE_MAP=4 -I include -I ../user/ -I ./ -I . -I . -I /opt/esp/sdk/include -o .output/eagle/debug/obj/Wifi.o -c Wifi.cpp
), but the linker now gives me this error:
xtensa-lx106-elf-gcc -L../lib -nostdlib -T../ld/eagle.app.v6.ld -Wl,--no-check-sections -Wl,--gc-sections -u call_user_start -Wl,-static -Wl,--start-group -lc -lgcc -lhal -lphy -lpp -lnet80211 -lm -llwip -lwpa -lcrypto -lmain -ljson -lupgrade -lmbedtls -lpwm -ldriver -Wl,-Map -Wl,"mapfile.map" -Wl,--cref -lsmartconfig user/.output/eagle/debug/lib/user.a BMP280/.output/eagle/debug/lib/BMP280.a Soft_I2C/.output/eagle/debug/lib/I2C.a SSD1306_OLED/.output/eagle/debug/lib/OLED.a WIFI/.output/eagle/debug/lib/WIFI.a Util/.output/eagle/debug/lib/Util.a Buffer/.output/eagle/debug/lib/Buffer.a -Wl,--end-group -o .output/eagle/debug/image/eagle.app.v6.out
/opt/esp/crosstool-NG/builds/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .output/eagle/debug/image/eagle.app.v6.out section `.text' will not fit in region `iram1_0_seg'
I attached the generated mapfile, but unfortunately I am not really familiar with the format and therefore don't know what I have to look for to solve this problem.
Anyone here who knows why suddenly '.text' won't fit into 'iram1_0_seg' anymore? If I replace those lambdas with functions and function-pointers, everything works fine.
Any help is greatly appreciated.