且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在VSCode中构建程序时,如何指定包含路径?

更新时间:2022-02-23 08:12:57

使用-I标志在args属性下指定tasks.json中的包含路径.

specify the include paths in tasks.json, under the args property, using the -I flag.

{
    "tasks": [
        {
            "type": "shell",
            "label": "gcc build active file",
            "command": "/usr/bin/gcc",
            "args": [
                "-g",
                "-Wall",
                "-Werror",
                "-Wextra",
                "-o0",
                "-I${workspaceFolder}/inc",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "group": {
            "kind": "build",
            "isDefault": true
            },
        }
    ],
    "version": "2.0.0"
}