Using c++ with ESP-IDF for ESP32 development

Using VS Code with PlatformIO extension…
I have been trying to program in c++ for development and adding standard c++ libraries. Finally realized that PlatformIO was overwriting c_cpp_properties.json everytime VS Code was started and deleting any includepath edit I had made. Found some snippets indicating that this is desired functionality and that the json should not be modifiable.

Could someone provide some input here. Is c++ programming not supported with ESP-IDF? Is there another method I should be using to add non-default libraries? (other than editing c_cpp_properties includepath).

may be obvious here but I wanted to use the ESP-IDF framework rather than arduino

Add this block to your main.cpp:


extern "C" {
    void app_main(void);
}

Example

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"

extern "C" {
    void app_main(void);
}

void app_main()
{
    printf("Hello PlatformIO!\n");
}
1 Like

Related to this is that PlatformIO is forcing the use of the current ESPIDF release (2.1) and I need to use the current unreleased version (discussed this here: PlatformIO is not updating ESP-IDF files). Would the build options allow this (Use Case: Get the latest GIT revision “on-the-fly”)???

I’m now working in Eclipse because of this and would love to switch back. If the above is true, could you provide me a bit more input on how to implement? Just found someone else asking about the same (Using esp32 idf master branch)…

Any reason in particular that you sent me link to examples?

I, now two years later, have the same problem as rweller59 and can’t find a working solution.
I don’t understand how the two Links should help me with fixing my problem.
Would you (@ivankravets ) please provide us/me with instructions about how to use the espidf with c++?

See updated comment Using c++ with ESP-IDF for ESP32 development - #2 by ivankravets

@ivankravets I have no idea what your new solution has with the two links from the former solution in common, but that doesn’t matter.
I really thank you for the very fast answer, my project now works as intended.

What do you mean? Have you seen updated solution above?

Ivan’s reply was responding to the two issues raised in the OPs - C++ AND include path being over-written. The link re: build_flags deals with the include paths. Plus the reply has been updated to show the actual code that was probably in one of the examples.