Platformio (Visual Code): Intellisense issues, cannot open source file stdlib.h (unrecognized command line option '-m64')

I ask the community to help me deal with a strange problem, details below:

Recently there was a problem with IntelliSense, it stopped working on the fly and errors appeared about “cannot open the source file” stdlib.h “(dependency of” Arduino.h “)”, before that I had not experienced such problems with PIO & VSCODE. It is not clear to me why this happened; I have not made any global changes (but updated the JRE?).

I tried to solve the problem myself, studied the existing problems and solutions discussed in the community, but have not yet achieved success.

What was done:

  • at the beginning I started by removing .vscode in the project directory and restarting VSCODE
  • library update
  • PIO core update
  • complete removal of the c: \ Users \ Derry \ .platformio directory
  • reinstall vscode
  • uninstall VSCODE and clean install VSCODE 1.41.0-insider (user setup)
  • now I have come to the dev kernel PIO

Unfortunately this problem remained. At the same time, there are no problems with the Build Task of projects.

Below is information on a fresh installation of VSCODE:

Errors in a clean project (unfortunately errors in screenshots in Russian):



Installed Extensions:
extensions

=================== pio upgrade

pio upgrade --dev

=================== VERSION
PlatformIO
Home 3.1.0-beta.2·Core 4.1.1b3

=================== .vscode\c_cpp_properties.json

{
    "configurations": [
        {
            "name": "!!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags"
        },
        {
            "name": "Win32",
            "includePath": [
                "d:/_Arduino/_Projects/test_project_1/include",
                "d:/_Arduino/_Projects/test_project_1/src",
                "C:/Users/Derry/.platformio/packages/framework-arduinoavr/cores/arduino",
                "C:/Users/Derry/.platformio/packages/framework-arduinoavr/variants/eightanaloginputs",
                "C:/Users/Derry/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/EEPROM/src",
                "C:/Users/Derry/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/HID/src",
                "C:/Users/Derry/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/SPI/src",
                "C:/Users/Derry/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/SoftwareSerial/src",
                "C:/Users/Derry/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/Wire/src",
                "C:/Users/Derry/.platformio/packages/tool-unity",
                ""
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "path": [
                    "d:/_Arduino/_Projects/test_project_1/include",
                    "d:/_Arduino/_Projects/test_project_1/src",
                    "C:/Users/Derry/.platformio/packages/framework-arduinoavr/cores/arduino",
                    "C:/Users/Derry/.platformio/packages/framework-arduinoavr/variants/eightanaloginputs",
                    "C:/Users/Derry/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/EEPROM/src",
                    "C:/Users/Derry/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/HID/src",
                    "C:/Users/Derry/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/SPI/src",
                    "C:/Users/Derry/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/SoftwareSerial/src",
                    "C:/Users/Derry/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/Wire/src",
                    "C:/Users/Derry/.platformio/packages/tool-unity",
                    ""
                ]
            },
            "defines": [
                "PLATFORMIO=40101",
                "ARDUINO_AVR_NANO",
                "F_CPU=16000000L",
                "ARDUINO_ARCH_AVR",
                "ARDUINO=10805",
                "__AVR_ATmega328P__",
                ""
            ],
            "intelliSenseMode": "clang-x64",
            "cStandard": "c11",
            "cppStandard": "c++11",
            "compilerPath": "\"C:/Users/Derry/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe\" -mmcu=atmega328p"
        }
    ],
    "version": 4
}

=================== src\main.cpp

#include <Arduino.h>

void setup()
{
  int a = 1;
  int b = 2;
  int c = a + b;
}

void loop()
{
  // put your main code here, to run repeatedly:
}

=================== platformio.ini

;PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:nanoatmega328new]
platform = atmelavr
board = nanoatmega328new
framework = arduino

=================== BUILD

> Executing task: C:\Users\Derry\.platformio\penv\Scripts\platformio.exe run <

Processing nanoatmega328new (platform: atmelavr; board: nanoatmega328new; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/nanoatmega328new.html
PLATFORM: Atmel AVR 1.15.0 > Arduino Nano ATmega328 (New Bootloader)
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 30KB Flash
PACKAGES: toolchain-atmelavr 1.50400.190710 (5.4.0), framework-arduinoavr 4.1.2
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\nanoatmega328new\src\main.cpp.o
Archiving .pio\build\nanoatmega328new\libFrameworkArduinoVariant.a
Compiling .pio\build\nanoatmega328new\FrameworkArduino\CDC.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\HardwareSerial.cpp.o
src\main.cpp: In function 'void setup()':
src\main.cpp:8:7: warning: unused variable 'c' [-Wunused-variable]
   int c = a + b;
       ^
Compiling .pio\build\nanoatmega328new\FrameworkArduino\HardwareSerial0.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\HardwareSerial1.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\HardwareSerial2.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\HardwareSerial3.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\IPAddress.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\PluggableUSB.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\Print.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\Stream.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\Tone.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\USBCore.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\WInterrupts.c.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\WMath.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\WString.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\abi.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\hooks.c.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\main.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\new.cpp.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\wiring.c.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\wiring_analog.c.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\wiring_digital.c.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\wiring_pulse.S.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\wiring_pulse.c.o
Compiling .pio\build\nanoatmega328new\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\nanoatmega328new\libFrameworkArduino.a
Linking .pio\build\nanoatmega328new\firmware.elf
Building .pio\build\nanoatmega328new\firmware.hex
Checking size .pio\build\nanoatmega328new\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.4% (used 9 bytes from 2048 bytes)
Flash: [          ]   1.4% (used 444 bytes from 30720 bytes)
================================================================================================= [SUCCESS] Took 3.19 seconds

=================== pio settings get

Name                       Current value [Default]                       Description
-------------------------  --------------------------------------------  --------------------------------------------------------
auto_update_libraries      No                                            Automatically update libraries (Yes/No)
auto_update_platforms      No                                            Automatically update platforms (Yes/No)
check_libraries_interval   7                                             Check for the library updates interval (days)
check_platformio_interval  3                                             Check for the new PlatformIO interval (days)
check_platforms_interval   7                                             Check for the platform updates interval (days)
enable_cache               Yes                                           Enable caching for API requests and Library Manager
enable_telemetry           Yes                                           Telemetry service <http://bit.ly/pio-telemetry> (Yes/No)
force_verbose              No                                            Force verbose output when processing environments
projects_dir               C:\Users\Derry\Documents\PlatformIO\Projects  Default location for PlatformIO projects (PIO Home)
strict_ssl                 No                                            Strict SSL for PlatformIO Services

=================== pio platform list

atmelavr ~ Atmel AVR
====================
Atmel AVR 8- and 32-bit MCUs deliver a unique combination of performance, power efficiency and design flexibility. Optimized to speed time to market-and easily adapt to new ones-they are based on the industrys most code-efficient architecture for C and assembly programming.

Home: http://platformio.org/platforms/atmelavr
Frameworks: arduino, simba
Packages: toolchain-atmelavr, framework-arduinoavr, framework-simba, tool-avrdude, tool-micronucleus
Version: 1.15.0

espressif8266 ~ Espressif 8266
==============================
Espressif Systems is a privately held fabless semiconductor company. They provide wireless communications and Wi-Fi chips which are widely used in mobile devices and the Internet of Things applications.

Home: http://platformio.org/platforms/espressif8266
Frameworks: arduino, esp8266-nonos-sdk, esp8266-rtos-sdk, simba
Packages: framework-esp8266-rtos-sdk, toolchain-xtensa, framework-simba, tool-esptool, tool-mkspiffs, tool-esptoolpy, framework-arduinoespressif8266, framework-esp8266-nonos-sdk
Version: 2.2.3

=================== pio init --ide vscode

The current working directory D:\_Arduino\_Projects\test_project_1 will be used for the project.

The next files/directories have been created in D:\_Arduino\_Projects\test_project_1
include - Put project header files here
lib - Put here project specific (private) libraries
src - Put project source files here
platformio.ini - Project Configuration File

Project has been successfully updated including configuration files for `vscode` IDE.

=================== ERRORS:

Обнаружены ошибки #include. Измените includePath. Волнистые линии отключены для этой единицы трансляции (D:\_Arduino\_Projects\test_project_1\src\main.cpp).
не удается открыть источник файл "stdlib.h" (dependency of "Arduino.h")

=================== Search results:

$ find /cygdrive/c/Users/Derry/.platformio -name stdlib.h
/cygdrive/c/Users/Derry/.platformio/packages/framework-arduinoespressif8266/tools/sdk/libc/xtensa-lx106-elf/include/machine/stdlib.h
/cygdrive/c/Users/Derry/.platformio/packages/framework-arduinoespressif8266/tools/sdk/libc/xtensa-lx106-elf/include/stdlib.h
/cygdrive/c/Users/Derry/.platformio/packages/toolchain-atmelavr/avr/include/stdlib.h
/cygdrive/c/Users/Derry/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/tr1/stdlib.h
/cygdrive/c/Users/Derry/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/machine/stdlib.h
/cygdrive/c/Users/Derry/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/stdlib.h
1 Like

I switched logs to debug mode and found an error when calling xtensa-lx106-elf-gcc.exe

Попытка получить значения по умолчанию из компилятора в свойстве "compilerPath": "C:/Users/Derry/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-gcc.exe"
xtensa-lx106-elf-gcc.exe: error: unrecognized command line option '-m64'

The reason for the problem was found:

Solution: return to version 0.26.2-insiders

2 Likes

I have the same issue, and I’m new to PlatformIO.

How do I do to:

Download:
https://github.com/microsoft/vscode-cpptools/releases/download/0.26.2-insiders/cpptools-win32.vsix

Install this vsix file from extensions menu “Install VSIX” (may need to disable dependent extensions beforehand)

1 Like

Thanks @DerMaister, that was a fast.
When I do try to “Install VSIX”, it does report:

Cannot uninstall extension ‘C/C++’. Extension ‘PlatformIO IDE’ depends on this.

…and It does not help to disable ‘PlatformIO IDE’.

Do I have to uninstall ‘PlatformIO IDE’, and start all over?

I also noticed that I could right click on the C/C++ extension and select “Install Another Version”, but there I could only back to v0.26.1.
I did try that, but that only worked temporary, just a minute later it got automatically updated to 0.26.2-insider2 again :cry:

Yes, you can remove the PIO temporarily and then install it again.
Also turn off the automatic extension updates in the settings of VS Code.

Yes, tried uninstalling it and found the auto update setting, and used it, and it now work after disabling the auto extension update.

Thanks again @DerMaister

1 Like

btw, VSCode has built in version management for extensions… so unless the insiders builds of the C/C++ engine are different, you should be able to use that to do the downgrade.

image

2 Likes

Really? This is the solution? I had to go back to 26.0 after it spontaneously broke itself. I am not up with the new kids, whats happened they broke it all in latest version?

This was the solution for me.

First disable auto updates of VS Code extensions:

Then follow pfeerick’s instructions to install 0.26.0.

Thanks to everyone that contributed to the solution :slight_smile:

1 Like

I am running into this issue now. Before finding this thread I assumed there was an issue with how PlatformIO was setting up the include & browse paths in .vscode/c_cpp_properties.json. I manually added the following to my include path, which fixed the issue. Perhaps this could be automated? I’m not sure if I actually included the correct copies because there are multiple version for the various toolchains and platforms, but I picked the ones that seemed the most reasonable for my project.

"includePath": [
  "C:/Users/s-bear/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include",
  "C:/Users/s-bear/.platformio/packages/toolchain-gccarmnoneeabi/lib/gcc/arm-none-eabi/5.4.1/include",
  "C:/Users/s-bear/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/5.4.1",
  "C:/Users/s-bear/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/5.4.1/arm-none-eabi",
  ...

I also tried downgrading the C/C++ extension to v 0.26, but that seemed to break code browsing even worse, so I restored it back to v 1.5.1. I also tried setting "C_Cpp.default.intelliSenseMode": "gcc-arm" but it didn’t seem to make any difference.

Editing the .vscode/c_cpp_properties is almost never the correct solution. Also the thread is already 2 years old and I’d be baffled if the current VSCode C/C++ extension still makes problems. What exact problem are you running into? #include <stdlib.h> not found, or Arduino.h not found?

Hi, i still have the error

cannot open source file "stdlib.h" (dependency of "Arduino.h")

Are there known solutions?

Does the project build?

Have you tried to delete the .vscode folder of the project and doing a Ctrl+Shift+P → Rebuild Intellisense?

The project build. Just tried to delete folder .vscode and rebuild but the problem is still there

What’s the platformio.ini?

Here it is

STM8 is a special case. It uses the SDCC compiler that VSCode (and a lot of other IDEs) don’t know how to handle, and so Intellisense is mostly wrong or missing. See also Erreurs #include détectées. Mettez à jour includePath. Les tildes sont désactivés pour cette unité de traduction · Issue #26 · platformio/platform-ststm8 · GitHub.

This has been tracked for over 4 years in Support SDCC as compiler · Issue #7146 · microsoft/vscode-cpptools · GitHub and request to support sdcc mcs51 declarations (__sfr, __sbit, etc) · Issue #2499 · microsoft/vscode-cpptools · GitHub with 0 interest from Microsoft

The best one can do is give intellise a little “hint” by adding

build_flags = -D_SDCC_

so that the Arduino.h header files at least choses some files which happen to exist in a local GCC or cl.exe installation…

1 Like

Ok, i assume in platformio.ini, right? Thank you!