小编Die*_*zzi的帖子

VSCode c ++ task.json包含路径和库

IntelliSense使用c_cpp_properties.json >> includePath查找自动完成的标头,但我注意到我仍然需要在task.json >> task >> args内部指定包含路径来进行构建。

我在文档中发现includePath与我在“ -I”中指定的路径几乎相同:

您为此设置指定的路径与通过-I开关发送给编译器的路径相同。解析源文件后,IntelliSense引擎会在尝试解析它们的同时,将这些路径添加到您的#include指令指定的文件之前。这些路径不是递归搜索的。*

链接

  1. 我是否通过指定构建工具的args中的所有库和包含目录来正确设置VSCode?还是应该以其他方式进行?
  2. 有人可以用不同的词来解释includePath和browser之间的区别吗?解释链接对我来说并不完全清楚

这是我的c_cpp_properties.json的示例:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "D:/github/dependencies/SDL2-2.0.8/include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "${workspaceFolder}/**"
                ]
            }
        }
    ],
    "version": 4
}
Run Code Online (Sandbox Code Playgroud)

和task.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g",
                "main2.cpp", …
Run Code Online (Sandbox Code Playgroud)

c++ g++ build visual-studio-code

5
推荐指数
3
解决办法
5290
查看次数

标签 统计

build ×1

c++ ×1

g++ ×1

visual-studio-code ×1