Visual Studio Code, ESP-IDF, C++ include errors?
Posted: Mon Sep 24, 2018 7:49 am
Hi everyone,
I've recently started playing with the ESP32 using the Arduino IDE, but have now tried to swap to the ESP-IDF and Visual Studio Code tool chain so I've got more control. I'm just starting out with C++, but have experience with other languages.
I've successfully installed the ESP tool chain, msys32 and mingw32 seem to be working okay - I can compile and flash the example 'hello world' program to the ESP32 from the mingw32 command line.
I've followed guides on setting up Visual Studio Code to work with the ESP-IDE and can compile and flash the 'hello world' program to the ESP32 from VS Code successfully.
However, I've been going round in circles trying to get access to the C++ string library. I need it to progress my program for the ESP32, which uses http_server, to analyse and act upon queries passes in the URL.
I've included string:
And have tried accessing it like this:
and
But I've been getting errors - VS Code couldn't find the include originally (for string), so I tried including string.h, but that had the same error. I've searched the net, found quite a few posts about this issue, but none of the solutions have worked for me. As a result of trying out various solutions, it seems IntelliSense is now picking up <string.h> and <string>, I'm able to r/click on the include and go to the definition, but when I try to build the code ('make' in the mingw32 terminal), I'm getting this error:
I've had pretty much the same issues with Eclipse as well - could compile example programs, but nothing that tried to use string.h. I've since given up on Eclipse - seems massively complicated compared to VS Code for no real gain, so I'm focusing on getting VS Code working properly for now.
Seems to me there's an issue with my C++ installation or path... but everything else compiles okay. Any ideas?
I've recently started playing with the ESP32 using the Arduino IDE, but have now tried to swap to the ESP-IDF and Visual Studio Code tool chain so I've got more control. I'm just starting out with C++, but have experience with other languages.
I've successfully installed the ESP tool chain, msys32 and mingw32 seem to be working okay - I can compile and flash the example 'hello world' program to the ESP32 from the mingw32 command line.
I've followed guides on setting up Visual Studio Code to work with the ESP-IDE and can compile and flash the 'hello world' program to the ESP32 from VS Code successfully.
However, I've been going round in circles trying to get access to the C++ string library. I need it to progress my program for the ESP32, which uses http_server, to analyse and act upon queries passes in the URL.
I've included string:
Code: Select all
#include <stdio.h>
#include <string.h>
Code: Select all
if (std::to_string(var) == "text") { blah }
Code: Select all
std::string text = "Hello!";
Code: Select all
$ make
Python requirements from C:/msys32/home/user/esp-idf/requirements.txt are satisfied.
CC build/main/main.o
C:/msys32/home/user/esp-test/main/main.c: In function 'gpio_get_handler':
C:/msys32/home/user/esp-test/main/main.c:164:10: error: 'std' undeclared (first use in this function)
if (std::to_string(GPIOs[n]) == param) {
^
C:/msys32/home/user/esp-test/main/main.c:164:10: note: each undeclared identifier is reported only once for each function it appears in
C:/msys32/home/user/esp-test/main/main.c:164:13: error: expected ')' before ':' token
if (std::to_string(GPIOs[n]) == param) {
^
make[1]: *** [/home/user/esp-idf/make/component_wrapper.mk:286: main.o] Error 1
make: *** [C:/msys32/home/user/esp-idf/make/project.mk:481: component-main-build] Error 2
Seems to me there's an issue with my C++ installation or path... but everything else compiles okay. Any ideas?