Skip to content

Instantly share code, notes, and snippets.

@liudonghua123
Created June 29, 2018 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liudonghua123/41a7f20b5911c7938f06a90351b0622a to your computer and use it in GitHub Desktop.
Save liudonghua123/41a7f20b5911c7938f06a90351b0622a to your computer and use it in GitHub Desktop.
Some configuration files for c/c++ dev on wsl of vscode.
c:/windows/sysnative/bash.exe -c "gcc -g %1 -o %2"
{
// 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
// https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/Debugger/gdb/Windows%20Subsystem%20for%20Linux.md
"version": "0.2.0",
"configurations": [{
"name": "(gdb) Bash on Windows Launch",
"type": "cppdbg",
"request": "launch",
"targetArchitecture": "x86",
"program": "${fileBasenameNoExtension}.out",
"args": [],
"stopAtEntry": false,
"cwd": "/mnt/c/Users/Liu.D.H/Desktop/C_WSL",
"environment": [],
"externalConsole": true,
"pipeTransport": {
"pipeCwd": "",
"pipeProgram": "c:/windows/sysnative/bash.exe",
"pipeArgs": ["-c"],
"debuggerPath": "/usr/bin/gdb",
},
// https://blog.csdn.net/houen_study/article/details/73136047
/*把linux路径转换成windows,这样code才能找到代码*/
"sourceFileMap": {
// "/mnt/c/Users/Liu.D.H/Desktop/C_WSL": "${workspaceFolder}"
"/mnt/c": "c:/",
"/mnt/d": "d:/",
"/mnt/e": "e:/",
},
"windows": {
"MIMode": "gdb",
"setupCommands": [{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
// https://github.com/Microsoft/vscode-cpptools/issues/1408
{
"description": "Do not disable ASLR for WSL",
"text": "set disable-randomization off",
"ignoreFailures": true
},
],
},
"logging": {
"engineLogging": true
},
"preLaunchTask": "gcc"
}]
}
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"runner": "terminal",
"tasks": [
{
"label": "run",
"type": "shell",
"command": "./${fileBasenameNoExtension}.out",
"problemMatcher": [],
},
{
"label": "gcc",
// method 1
// "command": "${workspaceFolder}/.vscode/gcc.bat",
// "args": [
// "${fileBasenameNoExtension}.c",
// "${fileBasenameNoExtension}.out"
// ],
// method 2
"type": "shell",
"command":"gcc -Wall -g ${fileBasenameNoExtension}.c -o ${fileBasenameNoExtension}.out",
"problemMatcher": {
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment