0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

C++におけるVSCode上の設定メモ

Last updated at Posted at 2024-11-09

目標

Ctrl+Shift+B でコンパイル作業を行い、Ctrl+Shift+R でコンパイルされたファイルを実行できるようにする。

tasks.jsonの設定

コンパイルや実行の設定

tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build active file",
            "type": "shell",
            "command": "g++",
            "args": [
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "group": "build",
            "problemMatcher": [
                "$gcc"
            ],
            "detail": "Compiles the active C++ source file and creates an executable."
        },
        {
            "label": "run active file",
            "type": "shell",
            "command": "${fileDirname}/${fileBasenameNoExtension}",
            "group": {
                "kind": "test",
                "isDefault": true
            },
            "problemMatcher": [],
            "detail": "Runs the executable of the active C++ source file."
        },
        {
            "type": "cppbuild",
            "label": "C/C++: gcc アクティブなファイルのビルド",
            "command": "/usr/bin/gcc",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "デバッガーによって生成されたタスク。"
        }
    ]
}

keybindings.jsonの設定

tasks.jsonに記述されたタスクをもとに、Ctrl+Shift+B でコンパイル作業を行い、Ctrl+Shift+R でコンパイルされたファイルを実行する。

keybindings.json
[
    {
        "key": "ctrl+shift+b",
        "command": "workbench.action.tasks.runTask",
        "args": "build active file"
    },
    {
        "key": "ctrl+shift+r",
        "command": "workbench.action.tasks.runTask",
        "args": "run active file"
    }
]

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?