ESP idf expected initializer before '__result_use_check'错误修复

今日为了一个新的功能,尝试ESP32最新的idf(master 分支 commit 055943e29),重新下载了idf和toolchain,在测试hello_world项目运行idf.py menuconfig的时候报了一个warnning:

CMake Warning at ~/Espressif/ESP32/esp-idf/tools/cmake/crosstool_version_check.cmake:8 (message):
Xtensa toolchain~/Espressif/ESP32/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc version 5.2.0 is not the supported version 8.2.0. Check Getting Started documentation or proceed at own risk.,

然后编译的时候通不过去,提示:

~/Espressif/ESP32/xtensa-esp32-elf/xtensa-esp32-elf/sys-include/stdlib.h:155:44: error: expected initializer before ‘__result_use_check’ void *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size(2) ^~~~~~~~~~~~~~~~~~
~/Espressif/ESP32/xtensa-esp32-elf/xtensa-esp32-elf/sys-include/stdlib.h:340:52: error: expected initializer before ‘__alloc_align’
void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
^~~~~~~~~~~~~
[77/737] Building CXX object nvs_flash/CMakeFiles/nvs_flash.dir/src/nvs_page.cpp.obj
ninja: build stopped: subcommand failed.

最开始我以为是toolchain的版本过低(一般不都是这样吗?逻辑上说更新了idf也应该更新toolchain),但是我运行~/Espressif/ESP32/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc结果版本就是8.2.0啊? 后来搜索一番发现其实说的是版本过高。回滚到5.2.0就可以了,编译就通过了。

你可能感兴趣的:(ESP32)