Good afternoon,
I am using Eclipse CDT (ESP-IDF) in order to work with a ESP32-S3-DevKitC-1 EVM.
After creating a new project, I get a main.c main file for my application.
Instead of using a c file, I would like to use C++ in order to work with class.
So I renamed my main file main.cpp and decleared the app_main(void) function extern "C" app_main(void).
When I do this, I manage to execute the app_main function but when I want to use some of the methods provided by ESP-IDF, for example esp_chip_info(...), the compiler does not found some references anymore.
For example :
esp_chip_info_t chip_info; => I get the errors (Type esp_chip_info_t could not be resolved).
esp_chip_info(&chip_info); => I get the error invalid arguments
these two lines are oK when I use a main.c file instead of C++ file.
At the beginning ot my main.cpp file, I put the include files in a extern "C" { ..... }
Do you know how to solve this problem please ?
Best regards,
Thomas TRUILHE
How to use C++ with ESP-IDF and FreeRTOS please ?
-
- Posts: 229
- Joined: Thu Jul 14, 2022 5:15 am
Re: How to use C++ with ESP-IDF and FreeRTOS please ?
You should NOT use extern "C" { ..... } around any header files provided by esp-idf. They're already taken care of. If you still have issues after removing the extern "C" { ..... }, post back. It should just work without any other modifications.At the beginning ot my main.cpp file, I put the include files in a extern "C" { ..... }
Re: How to use C++ with ESP-IDF and FreeRTOS please ?
My whole application is in C++. The only thing you need to do is extern the main C entry point since ESP-IDF expects that to be a C function:
Code: Select all
extern "C" void app_main()
{
....
}
Who is online
Users browsing this forum: FabricioESP, martins and 16 guests