Visual Studio Code - fordsfords/fordsfords.github.io GitHub Wiki

See https://blog.geeky-boy.com/2023/08/visual-studio-code.html for the why.

This page is probably going to be random notes of things I tend to forget easily.

I set up VS Code on my work laptop, a Windows machine with WSL enabled (Ubuntu, if you're curious - I spend most of my non-Office/browser work time inside WSL shells.)

In the project directory:

$ code .

To set up the build, select the C file and hit the "run" button (upper-right - a triangle "play" icon). It will ask you some questions (I chose gcc) and sets up an initial cut of ".vscode/tasks.json". Edit this to add/subtract command-line parameters. Here's my example for the "q" program:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc build active file",
            "command": "/usr/bin/gcc",
            "args": [
                "-g",
                "-DCACHE_LINE_SIZE=64",
                "-DSELFTEST",
                "-pthread",
                "q.c",
                "-o",
                "${fileDirname}/q_selftest"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}