c_cpp_proprties.json
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++98",
"intelliSenseMode": "macos-clang-x64"
}
],
"version": 4
}
lauch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"cwd": "${workspaceFolder}",
"preLaunchTask": "C/C++: clang++ 生成活动文件"
}
]
}
settings.json
{
"editor.fontSize": 14,
"window.zoomLevel": 0,
// 添加希望被忽略的文件,这样一些文件虽然存在于当前工作目录下,但是不会被显示在左侧的文件浏览器里
"files.exclude": {
// dSYM文件具有调试信息,普通使用的话不看到它就可以了
"**/*.dSYM": true,
"**/*.out": true,
},
// --------------------------------------------------------------------------------------
// Code Runner
// To run code:
// use shortcut "Ctrl Opt N" *
// or press F1 and then select/type Run Code,
// or right click the Text Editor and then click Run Code in editor context menu
// or click Run Code button in editor title menu
// or click Run Code button in context menu of file explorer
// To stop the running code:
// use shortcut "Ctrl Opt M" *
// or press F1 and then select/type Stop Code Run
// or right click the Output Channel and then click Stop Code Run in context menu
"code-runner.executorMap": {
// Introduction:
// Make sure the executor PATH of each language is set in the environment variable.
// You could also add entry into "code-runner.executorMap" to set the executor PATH.
// Supported customized parameters:
// $workspaceRoot: The path of the folder opened in VS Code
// $dir: The directory of the code file being run
// $fullFileName: The full name of the code file being run
// $fileName: The base name of the code file being run, that is the file without the directory
// $fileNameWithoutExt: The base name of the code file being run without its extension
/* ------ 编译、运行只有一个文件的cpp文件 ------ */
// 注:路径中有空格不会出现问题
"cpp": "g++ $fullFileName -o $dir\"$fileNameWithoutExt\"\".out\" -W -Wall -O2 -std=c++17 && open -a terminal $dir\"$fileNameWithoutExt\"\".out\"",
// 其中 $fullFileName 是绝对路径,是主文件
// 自己决定是否加入 && rm $dir\"$fileNameWithoutExt\"\".out\"(也可以添加"files.exclude")
/* ------ 编译、运行多个cpp文件 ------ */
// "cpp": "g++ $fullFileName <file_to_link> -o $dir\"$fileNameWithoutExt\"\".out\" -W -Wall -O2 -std=c++17 && $dir\"$fileNameWithoutExt\"\".out\"",
// <file_to_link>的写法:
// 一般的,你也可以直接写绝对路径
// \"/path/xxxx.cpp\"
// 如果你链接的cpp文件和主文件在一个目录下:
// $dir\"xxxx.cpp\"
// 更一般的,如果你链接的cpp文件不和主文件在一个目录下,需要从当前VSCode的工作目录补充相对路径从而形成绝对路径:
// $workspaceRoot\"relative/path/xxxx.cpp\"
/* ------ 编译c文件 ------ */
"c": "gcc $fullFileName -o $dir\"$fileNameWithoutExt\"\".out\" -W -Wall -O2 -std=c17 && $dir\"$fileNameWithoutExt\"\".out\"",
// "c": "gcc $fullFileName <file_to_link> -o $dir\"$fileNameWithoutExt\"\".out\" -W -Wall -O2 -std=c17 && $dir\"$fileNameWithoutExt\"\".out\"",
},
// Whether to clear previous output before each run (default is false):
"code-runner.clearPreviousOutput": true,
// Whether to save all files before running (default is false):
"code-runner.saveAllFilesBeforeRun": false,
// Whether to save the current file before running (default is false):
"code-runner.saveFileBeforeRun": true,
// Whether to show extra execution message like [Running] ... and [Done] ... (default is true):
"code-runner.showExecutionMessage": false, // cannot see that message is you set "code-runner.runInTerminal" to true
// Whether to run code in Integrated Terminal (only support to run whole file in Integrated Terminal, neither untitled file nor code snippet) (default is false):
"code-runner.runInTerminal": true, // cannot input data when setting to false
// Whether to preserve focus on code editor after code run is triggered (default is true, the code editor will keep focus; when it is false, Terminal or Output Channel will take focus):
"code-runner.preserveFocus": false,
// Whether to ignore selection to always run entire file. (Default is false)
"code-runner.ignoreSelection": true,
"files.associations": {
"iostream": "cpp"
},
// --------------------------------------------------------------------------------------
}
take.json
{
"tasks": [
{
"externalConsole":true,
"type": "cppbuild",
"label": "C/C++: clang++ 生成活动文件",
"command": "/usr/bin/clang++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}