- Notifications
You must be signed in to change notification settings - Fork0
liusitan/Leetcode-CPP-Debug-Setup-Tutorial
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This tutorial helps the leetcoders who are not familiar with c++ quickly setup their debugging environment with ease. Although there are vscode extensions out there, I found them hard to use, especially for their poor support for data structure like trees, and meta script addition to original leetcode file. Before following this tutorial, you should make sure you have your own c++ compiler, vscode [leetcode]{https://marketplace.visualstudio.com/items?itemName=LeetCode.vscode-leetcode} extension installed. In future, more data structure builder will be added in this repo.
open your target leetcode file for debugging
In Run and Debug Section: launch leetcode debug
At the bottom of Solution Class:type Debug to invoke the template:
{"tasks": [ {"type":"cppbuild","label":"C/C++: clang++ build active file","command":"/usr/bin/clang++","args": ["-fdiagnostics-color=always","-g","${file}","-DSITAN=1","-o","${fileDirname}/leetcode.out" ],"options": {"cwd":"${fileDirname}" },"problemMatcher": ["$gcc" ],"group": {"kind":"build","isDefault":true },"detail":"Task generated by Debugger." } ],"version":"2.0.0"}
{// Use IntelliSense to learn about possible attributes.// Hover to view descriptions of existing attributes.// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387"version":"0.2.0","configurations": [ {"name":"leetcode debug","type":"cppdbg","request":"launch","program":"${workspaceFolder}/leetcode.out","preLaunchTask":"C/C++: clang++ build active file","args": [],"stopAtEntry":false,"cwd":"${fileDirname}","environment": [],"externalConsole":false,"MIMode":"lldb" } ]}
add snippets to your_leetcode_repo_directory/.vscode/snippets.leetcode.code-snippets to enable auto template completion.
{"Debug template": {"scope": "cpp","prefix": "DEBUG","body": ["#if defined(SITAN)","int main(){"," $0","}","#endif"]}}
To enable correct highlighting, in your c/c++ extension settings(remember to switch setting scope to your own workspace!!!):
modify C_Cpp.default.compilerArgs to -DSITAN=1.
About
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.