0

I have just installed the newest version of VScode, plus the Arduino extension and the the newest ESP-IDF and am trying to program an adafruit esp32 feather.

When using code that I wrote in Arduino IDE version 1.8.15, and also tested in the beta Arduino-DE 2.0.9, I have no errors that show up whatsoever.

An Initial sample being:

#include <array>
//#include <utility/imumaths.h>
//#include <driver/adc.h>
#include <MPU9250.h>
#include <Madgwick.h>
#include <TaskScheduler.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
#include <driver/adc.h>
//#define betaDef = 10f;
Adafruit_BNO055 bno = Adafruit_BNO055(-1, 0x28);
std::array<std::array<float, 3> , 2> vals = {0};
void taskPrint();

//Tasks
Task t1(1, TASK_FOREVER, &taskPrint);

Scheduler runner;

void taskPrint() {
  Serial.print(vals[0][0]);
  Serial.print(',');
  Serial.print(vals[0][1]);
  Serial.print(',');
  Serial.print(vals[0][2]);
  Serial.print(',');
  Serial.print(vals[1][0]);
  Serial.print(',');
  Serial.print(vals[1][1]);
  Serial.print(',');
  Serial.println(vals[1][2]);
};

the first error (namespace "std" has no member "array") on line 13.

When using the same code in VScode, Vscode verifies, complains, but compiles and uploads anyways (where the code continues to work fine on the esp32). With constant squiggle marks and errors.

I have checked the c_cpp_properties, where it appears version c++11 is being used by esp-idf.

"version": 4,
    "configurations": [
        {
            "name": "Arduino",
            "compilerPath": "C:\\Users\\computer\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-97-gc752ad5-5.2.0\\bin\\xtensa-esp32-elf-g++",
            "compilerArgs": [
                "-std=gnu++11",
                "-Wpointer-arith",
                "-fexceptions",
                "-fstack-protector",
                "-ffunction-sections",
                "-fdata-sections",
                "-fstrict-volatile-bitfields",
                "-mlongcalls",
                "-nostdlib",
                "-w",
                "-Wno-error=maybe-uninitialized",
                "-Wno-error=unused-function",
                "-Wno-error=unused-but-set-variable",
                "-Wno-error=unused-variable",
                "-Wno-error=deprecated-declarations",
                "-Wno-unused-parameter",
                "-Wno-unused-but-set-parameter",
                "-Wno-missing-field-initializers",
                "-Wno-sign-compare",
                "-fno-rtti"
            ],
            "intelliSenseMode": "gcc-x64",
            "includePath": [
            //a whole tonne of paths
]
"forcedInclude":["C:\\Users\\computer\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\cores\\esp32\\Arduino.h"
],
"cStandard": "c11",
"cppStandard": "c++11",
"defines": [ tonnes of defines 

            ]
        }
    ]
}

checking the cpp ref for std::array this should be supported in cp++11

Modifying this file simply causes Vscode to overwrite it with the original settings, because of this error, I can only assume the other errors I get are related (all seem to have to have various problems with my arrays.

namespace "std" has no member "array"C/C++(135)
identifier "vals" is undefinedC/C++(20)
qualified name is not allowedC/C++(283)
explicit type is missing ('int' assumed)C/C++(260)
mag_offsets" is not a nonstatic data member or base class of class "euler"C/C++(292)

Though I'm pretty bad at coding, I'm pretty sure that this issue has something to do with the program or compiler setup, and not my lack of ability.

How can I fix this namespace issue? I would like to use Vscode for programming my embedded projects...but at the moment, I get nothing but seemingly false reports from Intellisense.

1 Answers1

0

It is a bit hard to reproduce your error without all the files but I would suggest using xtensa-esp32-elf-gcc instead of xtensa-esp32-elf-g++ in compilerPath since the Microsoft C/C++ extension seems to work with gcc instead.

Another issue might be a conflict reference in includePaths or defines. I would suggest removing them if first approach didn't work.