How do I specify the include path when I build a program in VSCode?

前端 未结 1 759
执念已碎
执念已碎 2020-12-18 14:26

Let\'s say this is my project.

file structure:

project_root
|-- inc
|   |-- header.h
|-- src
|   |-- helpers.c
|   |-- main.c

1条回答
  •  悲哀的现实
    2020-12-18 15:04

    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"
    }
    

    0 讨论(0)
提交回复
热议问题