Vscode-cpptools: Just Can't Solve includePath errors

Created on 28 Mar 2018  路  19Comments  路  Source: microsoft/vscode-cpptools

I'm writing Arduino sketches and trying to switch over to VS Code for the de-bugging features. I can get the blink example to load and get NO errors.

When I load my own sketch that located in the C:/Users/ directory, then I get the "cannot open source file" error. I have read everything concerning this issue, but just can't solve it.

Any help is greatly appreciated. I've banged my head long enough.

Here are my versions,
VS Code - 1.21.1
Windows10
Arduino Extension 0.2.11
C/C++ Extension 0.15.0

Here's the error,

include errors detected. Please update your includePath. IntelliSense features for this translation unit (C:\Users\Greg\Projects\2018\Humidity Sensor\Source Code\HT18\HT18.ino) will be provided by the Tag Parser.

And lastly, here is my c_cpp_properties.json file,

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_GFX-Library",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_ILI9341",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_STMPE610",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_AM2315",
                    "C:\\Users\\Greg\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.6.18\\cores\\arduino",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\SD",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire",
                    "C:\\Users\\Greg\\Projects\\2018\\HumiditySensor\\SourceCode\\HT18\\HT18.ino"

            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": false,
                "path": [
                    "${workspaceFolder}",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_GFX-Library",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_ILI9341",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_STMPE610",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_AM2315",
                    "C:\\Users\\Greg\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.6.18\\cores\\arduino",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\SD",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire",
                    "C:\\Users\\Greg\\Projects\\2018\\HumiditySensor\\SourceCode\\HT18\\HT18.ino"

                ]
            },
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 3
}
Language Service fixed (release pending) question

Most helpful comment

OK, forget the above post. Everything is working. No Errors.

This article was helpful,
http://cuneyt.aliustaoglu.biz/en/enabling-arduino-intellisense-with-visual-studio-code/

Why I couldn't find that a couple of days ago .... : )

Thank you Bob for your help.

All 19 comments

#include errors detected. Please update your includePath. 

Your posted config does now have an includePath, only a browse/path - have you set it elsewhere?

Don't know why that didn't come thru. But, yes I have the includPath above the browse/path. Let me post again. Thanks for the reply.

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_GFX-Library",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_ILI9341",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_STMPE610",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_AM2315",
                    "C:\\Users\\Greg\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.6.18\\cores\\arduino",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\SD",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire",
                    "C:\\Users\\Greg\\Projects\\2018\\HumiditySensor\\SourceCode\\HT18\\HT18.ino"

            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": false,
                "path": [
                    "${workspaceFolder}",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI\\src",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_GFX-Library",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_ILI9341",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_STMPE610",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\Adafruit_AM2315",
                    "C:\\Users\\Greg\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.6.18\\cores\\arduino",
                    "C:\\ProgramFiles(x86)\\Arduino\\libraries\\SD",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SPI",
                    "C:\\ProgramFiles(x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire",
                    "C:\\Users\\Greg\\Projects\\2018\\HumiditySensor\\SourceCode\\HT18\\HT18.ino"

                ]
            },
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 3
}

My apologies, but when I copy and paste the code over, it only put half of it into the gray box. When I figure this issue out, I'll post the full c_cpp_properties.json file.

New to GitHub

use 3 backticks (`) when marking multiple lines of "code". I will edit your comments so that they show up properly.

Try setting the "intellisenseMode" to "clang-x64". If you still have #include errors after that, please let us know which files the extension is unable to find.

I tried 3 back ticks and it still didn't show all. Thanks.

I changed the intellisensenMode to clang-x64 and these are the files unable to find,

#include <SPI.h>;
#include<Wire.h>;
#include<Adafruit_GFX.h>;
#include<Adafruit_ILI9341.h>;
#include<Adafruit_STMPE610.h>;
#include<SoftwareSerial.h>;
#include<SD.h>;
#include<Adafruit_AM2315.h>;

It's not finding any libraries.
Just for reference, this code does compile and upload with the Arduino IDE.

Where do those files live in your filesystem? Are those paths included in the "includePath" setting? Or is this a green squiggle and you need to hover over it to see which dependency of these header files cannot be found?

Oh wait, I missed something. Your include path appears to be missing spaces in C:\\Program Files (x86)\\...

OK, now I'm getting somewhere. You were correct. I was missing spaces in those C://Program Files (x86)

Added spaces and still have errors but they have Cannot open source file "stdlib.h" (dependency of "SPI.h")

I have the SPI.h library path added to the includePath and the browse path

The files live in the paths that are shown in the above posts. If I understand your question correctly.

ok, if it can't find stdlib.h, then it probably means the "includePath" is missing your system includes. We are making a change in 0.16.0 to remove the requirement to put system includes in the "includePath" if you point us to your compiler via the new "compilerPath" property. You can try out the insiders build if you want a preview, but we are hoping to release the final package sometime today.

If you would rather wait for the final release, you can run [compiler] -v -E -x c++ nul to see what your system include paths are and add them to the "includePath" yourself.

I'll wait for the final release. Thanks for the help.

I've added the paths as highlighted in red, but still getting errors. What's the proper paths?

edit gcc include paths

OK, forget the above post. Everything is working. No Errors.

This article was helpful,
http://cuneyt.aliustaoglu.biz/en/enabling-arduino-intellisense-with-visual-studio-code/

Why I couldn't find that a couple of days ago .... : )

Thank you Bob for your help.

Oh, it's interesting that that article says to set "C_Cpp.intelliSenseEngine": "Tag Parser". That is the degraded IntelliSense experience, but it's probably what made your squiggles go away.

MacOS   : 10.13.4
VS Code  : 1.22.1
CPP Tools: 0.16.1

I was have a similar issue--embedded project using ARM GCC tools and libraries with many associated headers. Setting "C_Cpp.intelliSenseEngine": "Tag Parser" fixed this for me.

In my case I had a directory lib that was one level above ${workspaceFolder} so I set browse.path to include this. I also tried added to includePath. Only after I set Tag Parser did it begin working.

            "browse": {
                "path": [
                    "${workspaceFolder}",
                    "${workspaceFolder}/../lib",
                    "/usr/local/include"
                ],

I'm pretty happy now but is this a bug? It now seems to be finding symbols that are defined deep in that lib directory but I wouldn't want miss out on the "un-degraded" IntelliSense experience.

@razed11 did you try setting the "compilerPath" property to point to your ARM GCC compiler? That should pick up the system include path and defines necessary to make the Default IntelliSense work better. You can even add additional compiler arguments to the "path" string and we'll forward them on when we query the compiler.

@razed11 Also, the includePath used by the "Default" intelliSenseEngine is not recursive (yet), if your missing includes were under your ${workspaceFolder} or lib..

[issue moved to #3512]

@redquartista, I moved your comment to a new issue. Please use that instead of this one.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jrieken picture jrieken  路  3Comments

vicatcu picture vicatcu  路  3Comments

montery8 picture montery8  路  3Comments

ismadelgad11 picture ismadelgad11  路  3Comments

chrisckc picture chrisckc  路  3Comments