如何配置,以便不必在 vscode 中键入 c 中 headers 的完整路径

问题描述 投票:0回答:1

我正在使用 vscode 进行测试,看看它在 c 中编辑代码的能力。我在配置标头路径时遇到问题,为了方便标头导入,因为我将它们放在单独的文件夹中进行组织,我配置了 Microsoft C/C++ 扩展以将 include 文件夹添加为标头的路径,但是似乎没有去上班

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/include"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c23",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-gcc-x64",
            "browse": {
                "path": [
                    "${workspaceFolder}/include",
                    "${workspaceFolder}/src"
                ],
                "limitSymbolsToIncludedHeaders": false,
                "databaseFilename": ""
            }
        }
    ],
    "version": 4
}

这是创建的c_cpp_properties文件,但它似乎没有做任何事情。

我仍然收到此错误:

Iniciando o build...
/usr/bin/gcc -fdiagnostics-color=always -g /home/user/Codes/C/TestProject/src/*.c -o /home/user/Codes/C/TestProject/src/../output/Main
/home/user/Codes/C/TestProject/src/Main.c:2:10: fatal error: List.h: No such file or directory
    2 | #include "List.h"
      |          ^~~~~~~~
compilation terminated.

Build concluída com erro(s).
c visual-studio-code configuration header-files
1个回答
0
投票

将路径添加到您的 .json 文件

      "includePath": ["${myDefaultIncludePath}", "/another/path"],
© www.soinside.com 2019 - 2024. All rights reserved.