PlatformIO Community

Error with includes involving variants using Arduino framework

There seems to be an issue involving the include directories that are auto-generated inside vscode. The error is in main.cpp, on the #include <Arduino.h> line.

Here are the errors:

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/home/callum/Documents/PlatformIO/Projects/Crypto Wallet/src/main.cpp).C/C++(1696)

cannot open source file "variant_BLACKPILL_F411CE.h" (dependency of "Arduino.h")C/C++(1696)

Basically, the variant file “variant_BLACKPILL_F411CE.h” isn’t in the includes directory. I fixed this by adding the directory:

/home/user/.platformio/packages/framework-arduinoststm32/variants/STM32F4xx/F411C(C-E)(U-Y)

to the list of includes in .vscode/c_cpp_properties.json, but every time I change something in the PlatformIO config, it regenerates this file and gets rid of the path.

Is there something I can change so the PlatformIO adds this to the list of include directories by itself?

Note: I am on Linux, I’m not sure if this has anything to do with the error because I am very new to PlatformIO.

Thanks!

Hm weird, I see the variant being correctly declared as

and this logic adds it as an include path

so I’m not sure what the issue would be. Please report this bug to Issues · platformio/platform-ststm32 · GitHub along with the used platformio.ini.

You may temporarily fix this IntelliSense issue by adding

build_flags = -I/home/user/.platformio/packages/framework-arduinoststm32/variants/STM32F4xx/F411C(C-E)(U-Y)

to the platformio.ini of the project.

Sorry, I should have said that it actually compiles just fine. The issue is just that the c/c++ extension in vscode doesn’t know about the header file because it isn’t in the c_cpp_properties.json file. Adding the build_flags thing actually stopped it from compiling.

I’m wondering if the bug is just that the variant folder isn’t added inside c_cpp_properties.json, but if this works for other people then maybe it’s just me?

Thanks for you help.

Please remove the build_flags again and do a Ctrl+Shift+P → Rebuild IntelliSense. Then post the content of the .vscode/c_cpp_properties.json.

Alright, here are the file contents:

{
    "configurations": [
        {
            "name": "PlatformIO",
            "includePath": [
                "/home/callum/Projects/Crypto Wallet/include",
                "/home/callum/Projects/Crypto Wallet/src",
                "/home/callum/Projects/Crypto Wallet/.pio/libdeps/blackpill_f411ce/U8g2/src",
                "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/Wire/src",
                "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/SPI/src",
                "/home/callum/Projects/Crypto Wallet/.pio/libdeps/blackpill_f411ce/uBitcoin/src",
                "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino/avr",
                "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32",
                "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/LL",
                "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb",
                "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/OpenAMP",
                "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb/hid",
                "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb/cdc",
                "/home/callum/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32F4xx_HAL_Driver/Inc",
                "/home/callum/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32F4xx_HAL_Driver/Src",
                "/home/callum/.platformio/packages/framework-arduinoststm32/system/STM32F4xx",
                "/home/callum/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc",
                "/home/callum/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src",
                "/home/callum/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP",
                "/home/callum/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/open-amp/lib/include",
                "/home/callum/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/libmetal/lib/include",
                "/home/callum/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/virtual_driver",
                "/home/callum/.platformio/packages/framework-cmsis/CMSIS/Core/Include",
                "/home/callum/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32F4xx/Include",
                "/home/callum/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc",
                "/home/callum/.platformio/packages/framework-cmsis/CMSIS/DSP/Include",
                "/home/callum/.platformio/packages/framework-cmsis/CMSIS/DSP/PrivateInclude",
                "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino",
                "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/CMSIS_DSP/src",
                "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/EEPROM/src",
                "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/IWatchdog/src",
                "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/Keyboard/src",
                "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/Mouse/src",
                "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/Servo/src",
                "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/SoftwareSerial/src",
                "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/SrcWrapper/src",
                // I add this line to fix IntelliSense: "/home/callum/.platformio/packages/framework-arduinoststm32/variants/STM32F4xx/F411C(C-E)(U-Y)",
                ""
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "path": [
                    "/home/callum/Projects/Crypto Wallet/include",
                    "/home/callum/Projects/Crypto Wallet/src",
                    "/home/callum/Projects/Crypto Wallet/.pio/libdeps/blackpill_f411ce/U8g2/src",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/Wire/src",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/SPI/src",
                    "/home/callum/Projects/Crypto Wallet/.pio/libdeps/blackpill_f411ce/uBitcoin/src",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino/avr",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/LL",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/OpenAMP",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb/hid",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb/cdc",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32F4xx_HAL_Driver/Inc",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32F4xx_HAL_Driver/Src",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/system/STM32F4xx",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/open-amp/lib/include",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/libmetal/lib/include",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/virtual_driver",
                    "/home/callum/.platformio/packages/framework-cmsis/CMSIS/Core/Include",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32F4xx/Include",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc",
                    "/home/callum/.platformio/packages/framework-cmsis/CMSIS/DSP/Include",
                    "/home/callum/.platformio/packages/framework-cmsis/CMSIS/DSP/PrivateInclude",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/cores/arduino",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/CMSIS_DSP/src",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/EEPROM/src",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/IWatchdog/src",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/Keyboard/src",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/Mouse/src",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/Servo/src",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/SoftwareSerial/src",
                    "/home/callum/.platformio/packages/framework-arduinoststm32/libraries/SrcWrapper/src",
                    ""
                ]
            },
            "defines": [
                "PLATFORMIO=50101",
                "STM32F4xx",
                "STM32F411xE",
                "STM32F4xx",
                "ARDUINO=10808",
                "ARDUINO_ARCH_STM32",
                "ARDUINO_BLACKPILL_F411CE",
                "BOARD_NAME=\"BLACKPILL_F411CE\"",
                "HAL_UART_MODULE_ENABLED",
                "USE_FULL_LL_DRIVER",
                "VARIANT_H=\"variant_BLACKPILL_F411CE.h\"",
                "CUSTOM_PERIPHERAL_PINS",
                ""
            ],
            "cStandard": "c11",
            "cppStandard": "c++14",
            "compilerPath": "/home/callum/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc",
            "compilerArgs": [
                "-mfpu=fpv4-sp-d16",
                "-mfloat-abi=hard",
                "-mcpu=cortex-m4",
                "-mthumb",
                ""
            ]
        }
    ],
    "version": 4
}

I commented out the fix that I’m using but you can see it at the bottom of the includePath list.

I can’t reproduce the problem.

When I create a new folder and do

pio init -b blackpill_f411ce --ide=vscode 

and inspect the generated .vscode/c_cpp_properties.json I get

//
// !!! WARNING !!! AUTO-GENERATED FILE!
// PLEASE DO NOT MODIFY IT AND USE "platformio.ini":
// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
//
{
    "configurations": [
        {
            "name": "PlatformIO",
            "includePath": [
                "/home/max/pio_tests/stm32_include/include",
                "/home/max/pio_tests/stm32_include/src",
                "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino/avr",
                "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32",
                "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/LL",
                "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb",
                "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/OpenAMP",
                "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb/hid",
                "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb/cdc",
                "/home/max/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32F4xx_HAL_Driver/Inc",
                "/home/max/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32F4xx_HAL_Driver/Src",
                "/home/max/.platformio/packages/framework-arduinoststm32/system/STM32F4xx",
                "/home/max/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc",
                "/home/max/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src",
                "/home/max/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP",
                "/home/max/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/open-amp/lib/include",
                "/home/max/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/libmetal/lib/include",
                "/home/max/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/virtual_driver",
                "/home/max/.platformio/packages/framework-cmsis/CMSIS/Core/Include",
                "/home/max/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32F4xx/Include",
                "/home/max/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc",
                "/home/max/.platformio/packages/framework-cmsis/CMSIS/DSP/Include",
                "/home/max/.platformio/packages/framework-cmsis/CMSIS/DSP/PrivateInclude",
                "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino",
                "/home/max/.platformio/packages/framework-arduinoststm32/variants/STM32F4xx/F411C(C-E)(U-Y)",
                "/home/max/.platformio/packages/framework-arduinoststm32/libraries/CMSIS_DSP/src",
                "/home/max/.platformio/packages/framework-arduinoststm32/libraries/EEPROM/src",
                "/home/max/.platformio/packages/framework-arduinoststm32/libraries/IWatchdog/src",
                "/home/max/.platformio/packages/framework-arduinoststm32/libraries/Keyboard/src",
                "/home/max/.platformio/packages/framework-arduinoststm32/libraries/Mouse/src",
                "/home/max/.platformio/packages/framework-arduinoststm32/libraries/SPI/src",
                "/home/max/.platformio/packages/framework-arduinoststm32/libraries/Servo/src",
                "/home/max/.platformio/packages/framework-arduinoststm32/libraries/SoftwareSerial/src",
                "/home/max/.platformio/packages/framework-arduinoststm32/libraries/SrcWrapper/src",
                "/home/max/.platformio/packages/framework-arduinoststm32/libraries/Wire/src",
                "/home/max/.platformio/packages/tool-unity",
                ""
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "path": [
                    "/home/max/pio_tests/stm32_include/include",
                    "/home/max/pio_tests/stm32_include/src",
                    "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino/avr",
                    "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32",
                    "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/LL",
                    "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb",
                    "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/OpenAMP",
                    "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb/hid",
                    "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb/cdc",
                    "/home/max/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32F4xx_HAL_Driver/Inc",
                    "/home/max/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32F4xx_HAL_Driver/Src",
                    "/home/max/.platformio/packages/framework-arduinoststm32/system/STM32F4xx",
                    "/home/max/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc",
                    "/home/max/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src",
                    "/home/max/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP",
                    "/home/max/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/open-amp/lib/include",
                    "/home/max/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/libmetal/lib/include",
                    "/home/max/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/virtual_driver",
                    "/home/max/.platformio/packages/framework-cmsis/CMSIS/Core/Include",
                    "/home/max/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32F4xx/Include",
                    "/home/max/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc",
                    "/home/max/.platformio/packages/framework-cmsis/CMSIS/DSP/Include",
                    "/home/max/.platformio/packages/framework-cmsis/CMSIS/DSP/PrivateInclude",
                    "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino",
                    "/home/max/.platformio/packages/framework-arduinoststm32/variants/STM32F4xx/F411C(C-E)(U-Y)",
                    "/home/max/.platformio/packages/framework-arduinoststm32/libraries/CMSIS_DSP/src",
                    "/home/max/.platformio/packages/framework-arduinoststm32/libraries/EEPROM/src",
                    "/home/max/.platformio/packages/framework-arduinoststm32/libraries/IWatchdog/src",
                    "/home/max/.platformio/packages/framework-arduinoststm32/libraries/Keyboard/src",
                    "/home/max/.platformio/packages/framework-arduinoststm32/libraries/Mouse/src",
                    "/home/max/.platformio/packages/framework-arduinoststm32/libraries/SPI/src",
                    "/home/max/.platformio/packages/framework-arduinoststm32/libraries/Servo/src",
                    "/home/max/.platformio/packages/framework-arduinoststm32/libraries/SoftwareSerial/src",
                    "/home/max/.platformio/packages/framework-arduinoststm32/libraries/SrcWrapper/src",
                    "/home/max/.platformio/packages/framework-arduinoststm32/libraries/Wire/src",
                    "/home/max/.platformio/packages/tool-unity",
                    ""
                ]
            },
            "defines": [
                "PLATFORMIO=50200",
                "STM32F4xx",
                "STM32F411xE",
                "STM32F4xx",
                "ARDUINO=10808",
                "ARDUINO_ARCH_STM32",
                "ARDUINO_BLACKPILL_F411CE",
                "BOARD_NAME=\"BLACKPILL_F411CE\"",
                "HAL_UART_MODULE_ENABLED",
                "USE_FULL_LL_DRIVER",
                "VARIANT_H=\"variant_BLACKPILL_F411CE.h\"",
                "CUSTOM_PERIPHERAL_PINS",
                ""
            ],
            "cStandard": "c11",
            "cppStandard": "c++14",
            "compilerPath": "/home/max/.platformio/packages/toolchain-gccarmnoneeabi@1.90201.191206/bin/arm-none-eabi-gcc",
            "compilerArgs": [
                "-mfpu=fpv4-sp-d16",
                "-mfloat-abi=hard",
                "-mcpu=cortex-m4",
                "-mthumb",
                ""
            ]
        }
    ],
    "version": 4
}

notice how there is

                "/home/max/.platformio/packages/framework-arduinoststm32/cores/arduino",
                "/home/max/.platformio/packages/framework-arduinoststm32/variants/STM32F4xx/F411C(C-E)(U-Y)",
                "/home/max/.platformio/packages/framework-arduinoststm32/libraries/CMSIS_DSP/src",

so the path information is there.

Please do a

pio upgrade --dev
pio platform update ststm32

in a CLI and retry project creation.

1 Like

I ran the two commands then created the project again and it seems to have solved the problem! Thanks so much for your help, I probably would have switched to Arduino IDE if I couldn’t get this solved.