Page 1 of 1

Not able to include standard c library headers in vs code esp-idf extension

Posted: Wed Jun 01, 2022 6:28 pm
by brand17
I am not able to include some standard libraries:

Code: Select all

#include <stdio.h> // <= this works
// #include <thread> // <= error: "No such file or directory"
// #include <algorithm> // <= error: "No such file or directory"

void app_main(void)
{

}
The error is generated by compiler xtensa-esp32-elf-gcc.exe. There is no error from C/C++ Intellisense. And I am able to find the necessary header by pressing F12. They are placed on the strange path C:\Espressif\tools\xtensa-esp32-elf\esp-2021r2-patch3-8.4.0\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\8.4.0. There is no such path in the compiler -I arguments.

How can I deal with this error?

Re: Not able to include standard c library headers in vs code esp-idf extension

Posted: Thu Jun 02, 2022 5:33 am
by brand17
Thread and algorithm are both part of C++ standard library, not C standard library. I've renamed the source file to .cpp (CMakeLists.txt was updated by VSCode automatically). Then I added:

Code: Select all

extern "C" {
   void app_main();
}
And it works.