[Solved] ESP32 Error: error: expected initializer before ‘__result_use_check‘

report errors:

A higher version of esp-idf was used before, but now a lower version of esp-idf should be used. There is an error in compiling after switching versions.

Execute make or make all

/home/pjw/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/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)
                                            ^~~~~~~~~~~~~~~~~~
/home/pjw/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/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)

Run make -j16

/home/pjw/ESP32/esp-mdf/esp-idf/components/newlib/include/stdio.h:282:12: error: 'vfiprintf' was not declared in this scope
 int _EXFUN(vfiprintf, (FILE *, const char *, __VALIST)
            ^~~~~~~~~
/home/pjw/ESP32/esp-mdf/esp-idf/components/newlib/include/stdio.h:282:29: error: expected primary-expression before '*' token
 int _EXFUN(vfiprintf, (FILE *, const char *, __VALIST)

....

a lot of errors

 

analysis:

ESP idf expected initializer before ‘__ result_ use_ Check ‘error repair
the first part of the compilation information is as follows:

App "get-started" version: 237cc099-dirty
WARNING: Toolchain version is not supported: esp-2020r3
Expected to see version: crosstool-ng-1.22.0-97-gc752ad5
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
WARNING: Compiler version is not supported: 8.2.0
Expected to see version(s): 5.2.0
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.

From the information point of view, the version of the compiled tool chain is incorrect
the esp-2020r3 version of tool chain is not supported. Use the crosstool-ng-1.22.0-97-gc752ad5 version
the 8.2.0 compiler is not supported. Use the 5.2.0 version.

 

solve:

After executing . Install. Sh in ESP IDF , the tool chain and compiler have been downloaded to ~ /. Espressif/tools/xtensa-esp32-elf .

So just modify the environment variables
the original export path = ~ /. Espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin: $path
modification:

vim ~/.bashrc

# Delete the previous compilation chain environment variables
#export PATH=~/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin:$PATH

# Add environment variables
export PATH=~/.espressif/tools/xtensa-esp32-elf/1.22.0-97-gc752ad5-5.2.0/xtensa-esp32-elf/bin:$PATH
source ~/.bashrc

P.S.
ESP-IDF release/v3.3 use 1.22.0-97-gc752ad5-5.2.0 version
ESP-IDF release/v4.0 use esp-2019r2-8.2.0 version
ESP-IDF release/v4.2 use esp-2020r3-8.4.0 version
ESP-IDF release/v4.3 use esp-2021r1-8.4.0 version


Read More: