VSCode添加头文件路径解决“cannot open source file “xxxx.h“”

导读:本篇文章讲解 VSCode添加头文件路径解决“cannot open source file “xxxx.h“”,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

  在下在使用VSCode的时候遇到了以下问题#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/home/pi/works/mqtt_demo/mqtt_client.c).C/C++(1696),虽然说我实际开发编译是通过编写Makefile实现的,对我实际开发并不造成影响,但是IDE老是那么红着,显示 ERROR ,实属不雅:
在这里插入图片描述
  那么问题来了,怎么给VSCode添加头文件的搜索路径呢?
1)在vscode中按Ctrl+Shift+P 输入configuration,选择C/C++:Edit Configuration(JSON);
在这里插入图片描述
2)编辑打开的c_cpp_properties.json文件,在configurations里的includePath中添加你需要引入的头文件的路径,保存即可。
修改前:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu17",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "linux-gcc-arm"
        }
    ],
    "version": 4
}

修改后:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/local/include/cjson/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu17",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "linux-gcc-arm"
        }
    ],
    "version": 4
}

  修改完成后,不显示 ERROR 了。
在这里插入图片描述

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/116946.html

(1)
seven_的头像seven_bm

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!