Those look like intellisense error messages from vscode. You likely have intellisense configuration issues. If the code compiles using the IDE then it will still compile when you use the vscode plugin since the plugin uses the ide to do the compile. You can optionally configure vscode build tasks and use the arduino cli.
If you want vscode to properly show the errors so you need to configure the vscode intellisense c_cpp_properties.json. It is important to understand that this file needs to be configured with the include paths and the proper build defines so that vscode lints the code properly.
If you are missing an include path, vscode cannot find it because it doesn't know the paths to the include files unless it is specified in the include paths. So, every include statement in your source files must have an include path in c_cpp_properties.json. I have found that recursive paths does not work for the arduino libraries folder for some reason. So, you need to specify each path individually. Here is a sample:
"includePath": [
"${workspaceRoot}/src/",
"/Users/stevenslupsky/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/**",
"/Users/stevenslupsky/Library/Arduino15/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include/**",
"/Users/stevenslupsky/Library/Arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/**",
"/Users/stevenslupsky/Library/Arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/samd21/**",
"/Users/stevenslupsky/Library/Arduino15/packages/arduino/hardware/samd/1.8.2/cores/arduino/",
"/Users/stevenslupsky/Library/Arduino15/packages/arduino/hardware/samd/1.8.2/variants/mkrwan1300/",
"/Users/stevenslupsky/Library/Arduino15/packages/arduino/hardware/samd/1.8.2/libraries/**",
"/Users/stevenslupsky/Library/Mobile Documents/com~apple~CloudDocs/Arduino/libraries/RTCZero/src/",
"/Users/stevenslupsky/Library/Mobile Documents/com~apple~CloudDocs/Arduino/libraries/Queue/src",
"/Users/stevenslupsky/Library/Mobile Documents/com~apple~CloudDocs/Arduino/libraries/jled/src/",
"/Users/stevenslupsky/Library/Mobile Documents/com~apple~CloudDocs/Arduino/libraries/SimplyAtomic/",
"/Users/stevenslupsky/Library/Mobile Documents/com~apple~CloudDocs/Arduino/libraries/Embedded_RingBuf_CPP/src/",
"/Users/stevenslupsky/Library/Mobile Documents/com~apple~CloudDocs/Arduino/libraries/witap/src/",
"/Users/stevenslupsky/Library/Mobile Documents/com~apple~CloudDocs/Arduino/libraries/Arduino-CommandLine/",
"/Users/stevenslupsky/Library/Mobile Documents/com~apple~CloudDocs/Arduino/libraries/ArduinoLog/",
"/Users/stevenslupsky/Library/Mobile Documents/com~apple~CloudDocs/Arduino/libraries/ArduinoLowPower/src/",
"/Users/stevenslupsky/Library/Mobile Documents/com~apple~CloudDocs/Arduino/libraries/arduino-ZeroRegs/src/",
"/Users/stevenslupsky/Library/Arduino15/packages/arduino/hardware/samd/1.8.2/**",
"/Users/stevenslupsky/Library/Arduino15/packages/arduino/tools/**"
],
Equally important is the linting requires that the defines for your build environment are properly specified as well. Here is a sample of the defines I use for a MKR WAN board:
"defines": [
"__CC_ARM",
"F_CPU=48000000L",
"ARDUINO=10607",
"ARDUINO_SAMD_MKRWAN1300",
"ARDUINO_ARCH_SAMD",
"USE_ARDUINO_MKR_PIN_LAYOUT",
"__SAMD21G18A__",
"USB_VID=0x2341",
"USB_PID=0x8053",
"USBCON",
"USE_BQ24195L_PMIC",
"VERY_LOW_POWER"
],
You should also force include "Arduino.h":
"forcedInclude": [
"/Users/stevenslupsky/Library/Arduino15/packages/arduino/hardware/samd/1.8.2/cores/arduino/Arduino.h"
],
And finally, use the arm compiler for linting as follows:
"intelliSenseMode": "gcc-x64",
"compilerPath": "/Users/stevenslupsky/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++",
"cStandard": "c11",
"cppStandard": "c++11"
Generally speaking, this configuration works pretty well for me.