Skip to content

Instantly share code, notes, and snippets.

@rohitsardessai
Last active July 11, 2023 20:17
Show Gist options
  • Save rohitsardessai/7b46f4a676b7d266dc87718cfd526bc5 to your computer and use it in GitHub Desktop.
Save rohitsardessai/7b46f4a676b7d266dc87718cfd526bc5 to your computer and use it in GitHub Desktop.
VSCode tasks.json file for debugging and testing a c program. The first task builds the program and creates an executable. The second task runs the program with valgrind to check for memory leaks. The executable is saved in a /build directory. The third, fourth and fifth are to be used with CMake.
{
"tasks": [
{
"type": "cppbuild",
"label": "R: C/C++: gcc-11 build active file",
"command": "/usr/bin/gcc-11",
"args": [
"-fdiagnostics-color=always",
"-g",
"${fileDirname}/**.c",
"-o",
"${fileDirname}/build/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
},
{
"type": "shell",
"label": "R: Run with Valgrind",
"command": "valgrind",
"args": [
"--leak-check=full",
"./build/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"group": {
"kind": "test",
"isDefault": false
},
"detail": "Run the program with Valgrind."
},
{
"label": "R: C/C++: cmake build",
"type": "shell",
"command": "cmake",
"args": [
"-S",
"${fileDirname}",
"-B",
"${fileDirname}/build"
],
"group": {
"kind": "build",
"isDefault": false
},
"detail": "CMake build task."
},
{
"label": "R: C/C++: make build",
"type": "shell",
"command": "make",
"args": [
"-C",
"${fileDirname}/build"
],
"group": {
"kind": "build",
"isDefault": false
},
"detail": "Make build task.",
"dependsOn": "R: C/C++: cmake build"
},
{
"label": "R: C/C++: CMake and make build",
"type": "shell",
"dependsOn": [
"R: C/C++: cmake build",
"R: C/C++: make build"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "CMake and make build task."
}
],
"version": "2.0.0"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment