简体   繁体   English

如何解决 Visual Studio Code Linux 中包含路径的问题?

[英]How to fix the problem of include Path in Visual Studio Code Linux?

I am using VSCode in Linux for my project.我在 Linux 中为我的项目使用 VSCode。 I have this curly line under the include lines of my header files我的头文件的包含行下面有这个卷线在此处输入图像描述

I included correctly the include path as defined in the file c_cpp_proprieties.json as follow:我正确地包含了文件 c_cpp_proprieties.json 中定义的包含路径,如下所示:

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

    }
],
"version": 4
}

Please any solution to resolve this problem.请任何解决方案来解决此问题。

When you compile it on gcc you have to include the include library.当你在 gcc 上编译它时,你必须包含包含库。 The include path in settings didn't work out for me.设置中的包含路径不适合我。 Changing it on the build task for gcc did fix it.在 gcc 的构建任务上更改它确实修复了它。

"tasks": [
    {
        "type": "cppbuild",
        "label": "C/C++: gcc build active file",
        "command": "/usr/bin/gcc",
        "args": [
            "-fdiagnostics-color=always",
            "-g",
            "-I",
            "${workspaceFolder}/ds/include/",
            "${workspaceFolder}/ds/src/${fileBasenameNoExtension}.c",      
            "-o",
            "${workspaceFolder}/${fileBasenameNoExtension}"
        ],
        "options": {
            "cwd": "${fileDirname}"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "detail": "compiler: /usr/bin/gcc"
    }
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM