首页 > 解决方案 > 自上次编译以来,如何让 VS Code 跳过源文件而没有任何更改?

问题描述

Eclipse CDT 可以自动编译项目目录中所有更改的源文件(如果有)并链接它们。然而,默认的“C/C++:g++.exe 构建活动文件”任务将始终编译该文件,即使自上次编译以来没有任何更改。是的,可以通过make文件来完成。除此之外,VSC 或其扩展是否提供了一些更简单的方法来做到这一点?

这是我的 tasks.json 的样子:

{
"version": "2.0.0",
"tasks": [
    {
        "type": "cppbuild",
        "label": "C/C++: g++.exe build active file",
        "command": "\"${config:task.gccpath}/g++.exe\"",
        "args": [
            "-Wall",
            "-g",
            "${file}",
            "-o",
            "${workspaceFolder}/Debug/${relativeFileDirname}/${fileBasenameNoExtension}.exe"
        ],
        "options": {
            "cwd": "${config:task.gccpath}"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "detail": "compiler: ${config:task.gccpath}/g++.exe"
    }
]
}

这是我的 launch.json 的样子

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
    {
        "name": "(gdb) Launch",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceFolder}/Debug/${relativeFileDirname}/${fileBasenameNoExtension}.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}/IO/${relativeFileDirname}/",
        "environment": [],
        "console": "externalTerminal",
        "MIMode": "gdb",
        "miDebuggerPath": "${config:task.gccpath}/gdb.exe",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
        "preLaunchTask": "C/C++: g++.exe build active file"
    }
]
}

标签: visual-studio-codemakefile

解决方案


推荐阅读