Skip to content

Instantly share code, notes, and snippets.

@dehanjl
Last active September 6, 2018 12:45
Show Gist options
  • Save dehanjl/89e99bf09dea61bed3b911d203845a97 to your computer and use it in GitHub Desktop.
Save dehanjl/89e99bf09dea61bed3b911d203845a97 to your computer and use it in GitHub Desktop.
VS Code Code Snippets and Setup Files
"Header Guard": {
"prefix": "#ifndef",
"body": [
"#ifndef $0${2:MACRO} // header guard",
"#define ${2:MACRO}",
"",
"",
"",
"#endif",
],
"description": "Apply header guard",
},
"Debug Log": {
"prefix": "debug",
"body": [
"std::clog << \"DEBUG: \" << __FILE__ << \":\" << __LINE__ << \" | \" << $0 << std::endl;",
],
"description": "Log message for debugging\n(Requires <iostream>)",
}
{
"version": "0.2.0",
"configurations": [
{
"name": "GDB WSL Launch",
"type": "cppdbg",
"request": "launch",
"program": "${command:extension.vscode-wsl-workspaceFolder}/cos110/assignments/ass_2/main.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${command:extension.vscode-wsl-workspaceFolder}/cos110/assignments/ass_2",
"environment": [],
"externalConsole": true,
"pipeTransport": {
"debuggerPath": "/usr/bin/gdb",
"pipeProgram": "${env:windir}\\system32\\bash.exe",
"pipeArgs": ["-c"],
"pipeCwd": ""
},
"windows": {
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
"sourceFileMap": {
"/mnt/d": "D:\\",
"/mnt/c": "C:\\",
}
},
]
}
"Skeleton Makefile (C++)": {
"scope": "makefile",
"prefix": "skeleton",
"body": [
"#variables",
"ofiles = $0${2:name}.o #list of object files",
"hfiles = #list of header files",
"sfiles = ${2:name}.cpp #list of source code files",
"zfiles = $(hfiles) $(sfiles) #list of files to zip",
"gpp = g++ -g -std=c++11 -Wall -Wextra #compiler options",
"gpp_o = $(gpp) -c",
"",
"all: ${2:name}.exe\n",
"run: ${2:name}.exe\n\t./${2:name}.exe\n",
"clean:\n\trm *.o *.exe\n",
"#linker",
"${2:name}.exe: $(ofiles)\n\t$(gpp) -o ${2:name}.exe $(ofiles)\n",
"#compile to object code",
"${2:name}.o: ${2:name}.cpp $(hfiles)\n\t$(gpp_o) ${2:name}.cpp",
"",
],
"description": "Set up a skeleton makefile (C++)",
},
"Object Compile (C++)": {
"scope": "makefile",
"prefix": "object",
"body": [
"$0${2:name}.o: ${2:name}.cpp ${2:name}.h #dependencies\n\t$(gpp_o) ${2:name}.cpp",
],
"description": "Compile to object code (C++), Requires $(gpp_o) to be set up",
},
"Zip Macro" : {
"scope": "makefile",
"prefix": "zip",
"body": [
"zip $0${2:archive}:\n\ttar -cvz $(zfiles) -f ${2:archive}.tar"
],
"description": "Set up zip macro, Requires $(zfiles) to be set up"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment