C/C++ for VS Code
Getting Started
To install the Microsoft C/C++ extension:
- Open VS Code.
- Click the Extensions View icon on the Sidebar.
- Search for
cpptools
. - Click Install, then click Enable.
- Open a folder that contains your C/C++ code.
You should now create a
tasks.json
file in your workspace .vscode
folder that looks something like:{After that you can generate a.out file by pressing CTRL+SHIFT+B.
"version": "0.1.0",
"command": "gcc",
"isShellCommand": true,
"showOutput": "always",
"args": ["-g","FILENAME.c"]
}
To enable debugging, you will need to create a launch.json file in .vscode folder :
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "/PATH/TO/WORKSPACE",
"environment": [],
"externalConsole": true,
"linux": {
"MIMode": "gdb"
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb"
}
},
{
"name": "C++ Attach",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceRoot}/a.out",
"processId": "${command.pickProcess}",
"linux": {
"MIMode": "gdb"
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb"
}
}
]
}
Comments
Post a Comment