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

brand17
Posts: 7
Joined: Wed Jun 01, 2022 6:16 pm

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

Postby brand17 » Wed Jun 01, 2022 6:28 pm

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?

brand17
Posts: 7
Joined: Wed Jun 01, 2022 6:16 pm

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

Postby brand17 » Thu Jun 02, 2022 5:33 am

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.

Who is online

Users browsing this forum: MicroController and 77 guests