Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Arduino work and not give "cannot open source file "avr/pgmspace.h"" on vscode?

I'm trying to program arduino in vscode. The problem is that It's giving me weird header errors: cannot open source file "avr/pgmspace.h" (dependency of "C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\Arduino.h")

This is my arduino.json:

    "board": "arduino:avr:uno"
}

This is my c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "C:\\Program Files (x86)\\Arduino\\tools\\**",
                "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\**"
            ],
            "forcedInclude": [
                "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Arduino.h"
            ],
            "intelliSenseMode": "msvc-x64",
            "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe",
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}

It should recursively include all of the required libraries, and even if imanually try to add the path to avr/pgmspace.h or its directory, it keeps giving me the same errors.

How do I solve this error?

like image 667
Fudge Fudge Avatar asked Jan 28 '19 09:01

Fudge Fudge


1 Answers

Based on the responses to this issue, I added "c:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr\\avr\\**" to my include path in c_cpp_properties.json:

"includePath": [
    "c:\\Program Files (x86)\\Arduino\\tools\\**",
    "c:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\**",
    "c:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr\\avr\\**"
],
like image 136
bonusmop Avatar answered Oct 05 '22 17:10

bonusmop