vscode新建文件夹

vscode新建文件夹下 .vscode的四个文件
文件“c_cpp_properties.json”

{
“configurations”: [
{
“name”: “MinGW”,
“intelliSenseMode”: “clang-x64”,
“compilerPath”: “C:/LLVM/bin/gcc.exe”,
“includePath”: [ “KaTeX parse error: Expected '}', got 'EOF' at end of input: … { "path": [ "{workspaceFolder}” ],
“limitSymbolsToIncludedHeaders”: true,
“databaseFilename”: “”
}, “cStandard”: “c11”, “cppStandard”: “c++17”
} ], “version”: 4
}

文件“launch.json“

// https://github.com/Microsoft/vscode-cpptools/blob/master/launch.md
{
“version”: “0.2.0”,
“configurations”: [ { “name”: “(gdb) Launch”, // 配置名称,将会在启动配置的下拉菜单中显示
“type”: “cppdbg”, // 配置类型,这里只能为cppdbg
“request”: “launch”, // 请求配置类型,可以为launch(启动)或attach(附加)
“program”: “ f i l e D i r n a m e / {fileDirname}/ fileDirname/{fileBasenameNoExtension}.exe”, // 将要进行调试的程序的路径
“args”: [], // 程序调试时传递给程序的命令行参数,一般设为空即可
“stopAtEntry”: false, // 设为true时程序将暂停在程序入口处,我一般设置为true
“cwd”: “${workspaceFolder}”, // 调试程序时的工作目录
“environment”: [], // (环境变量?)
“externalConsole”: true, // 调试时是否显示控制台窗口,一般设置为true显示控制台
“internalConsoleOptions”: “neverOpen”, // 如果不设为neverOpen,调试时会跳到“调试控制台”选项卡,你应该不需要对gdb手动输命令吧?
“MIMode”: “gdb”, // 指定连接的调试器,可以为gdb或lldb。但目前lldb在windows下没有预编译好的版本。
“miDebuggerPath”: “gdb.exe”, // 调试器路径,Windows下后缀不能省略,Linux下则去掉
“setupCommands”: [ // 用处未知,模板如此
{
“description”: “Enable pretty-printing for gdb”,
“text”: “-enable-pretty-printing”,
“ignoreFailures”: false } ],
“preLaunchTask”: “Compile” // 调试会话开始前执行的任务,一般为编译程序。与tasks.json的label相对应
}
]
}

文件“settings.json”

{
“files.defaultLanguage”: “cpp”, // ctrl+N新建文件后默认的语言
“editor.formatOnType”: true, // 输入时就进行格式化,默认触发字符较少,分号可以触发
“editor.snippetSuggestions”: “top”, // snippets代码优先显示补全
“code-runner.runInTerminal”: true, // 设置成false会在“输出”中输出,无法输入
“code-runner.executorMap”:
{
“c”: “cd $dir && clang $fileName -o $fileNameWithoutExt.exe -Wall -g -Og -static-libgcc -fcolor-diagnostics --target=x86_64-w64-mingw -std=c11 && d i r dir dirfileNameWithoutExt”,
“cpp”: “cd $dir && clang++ $fileName -o $fileNameWithoutExt.exe -Wall -g -Og -static-libgcc -fcolor-diagnostics --target=x86_64-w64-mingw -std=c++17 && d i r dir dirfileNameWithoutExt” }, // 设置code runner的命令行
“code-runner.saveFileBeforeRun”: true, // run code前保存
“code-runner.preserveFocus”: true, // 若为false,run code后光标会聚焦到终端上。如果需要频繁输入数据可设为false
“code-runner.clearPreviousOutput”: false, // 每次run code前清空属于code runner的终端消息
“C_Cpp.clang_format_sortIncludes”: true, // 格式化时调整include的顺序(按字母排序)
“C_Cpp.intelliSenseEngine”: “Default”, // 可以为Default或Tag Parser,后者较老,功能较简单。具体差别参考cpptools扩展文档
“C_Cpp.errorSquiggles”: “Disabled”, // 因为有clang的lint,所以关掉
“C_Cpp.autocomplete”: “Disabled”, // 因为有clang的补全,所以关掉
“clang.cflags”:
[ // 控制c语言静态检测的参数
“–target=x86_64-w64-mingw”, “-std=c11”, “-Wall”
],
“clang.cxxflags”:
[ // 控制c++静态检测时的参数
“–target=x86_64-w64-mingw”, “-std=c++17”, “-Wall”
], “clang.completion.enable”:true // 效果效果比cpptools要好
}

文件“tasks.json“

// https://code.visualstudio.com/docs/editor/tasks
{
“version”: “2.0.0”, “tasks”:
[
{ “label”: “Compile”, // 任务名称,与launch.json的preLaunchTask相对应
“command”: “clang++”, // 要使用的编译器
“args”: [ “ f i l e " , " − o " , / / 指 定 输 出 文 件 名 , 不 加 该 参 数 则 默 认 输 出 a . e x e , L i n u x 下 默 认 a . o u t " {file}", "-o", // 指定输出文件名,不加该参数则默认输出a.exe,Linux下默认a.out " file","o",//a.exeLinuxa.out"{fileDirname}/ f i l e B a s e n a m e N o E x t e n s i o n . e x e " , " − g " , / / 生 成 和 调 试 有 关 的 信 息 " − W a l l " , / / 开 启 额 外 警 告 " − s t a t i c − l i b g c c " , / / 静 态 链 接 " − f c o l o r − d i a g n o s t i c s " , / / 彩 色 的 错 误 信 息 ? 但 貌 似 c l a n g 默 认 开 启 而 g c c 不 接 受 此 参 数 " − − t a r g e t = x 8 6 6 4 − w 64 − m i n g w " , / / c l a n g 的 默 认 t a r g e t 为 m s v c , 不 加 这 一 条 就 会 找 不 到 头 文 件 ; L i n u x 下 去 掉 这 一 条 " − s t d = c + + 17 " / / C 语 言 最 新 标 准 为 c 11 , 或 根 据 自 己 的 需 要 进 行 修 改 ] , / / 编 译 命 令 参 数 " t y p e " : " s h e l l " , / / 可 以 为 s h e l l 或 p r o c e s s , 前 者 相 当 于 先 打 开 s h e l l 再 输 入 命 令 , 后 者 是 直 接 运 行 命 令 " g r o u p " : " k i n d " : " b u i l d " , " i s D e f a u l t " : t r u e / / 设 为 f a l s e 可 做 到 一 个 t a s k s . j s o n 配 置 多 个 编 译 指 令 , 需 要 自 己 修 改 本 文 件 , 我 这 里 不 多 提 , " p r e s e n t a t i o n " : " e c h o " : t r u e , " r e v e a l " : " a l w a y s " , / / 在 “ 终 端 ” 中 显 示 编 译 信 息 的 策 略 , 可 以 为 a l w a y s , s i l e n t , n e v e r 。 具 体 参 见 V S C 的 文 档 " f o c u s " : f a l s e , / / 设 为 t r u e 后 可 以 使 执 行 t a s k 时 焦 点 聚 集 在 终 端 , 但 对 编 译 c 和 c + + 来 说 , 设 为 t r u e 没 有 意 义 " p a n e l " : " s h a r e d " / / 不 同 的 文 件 的 编 译 信 息 共 享 一 个 终 端 面 板 / / " p r o b l e m M a t c h e r " : " {fileBasenameNoExtension}.exe", "-g", // 生成和调试有关的信息 "-Wall", // 开启额外警告 "-static-libgcc", // 静态链接 "-fcolor-diagnostics", // 彩色的错误信息?但貌似clang默认开启而gcc不接受此参数 "--target=x86_64-w64-mingw", // clang的默认target为msvc,不加这一条就会找不到头文件;Linux下去掉这一条 "-std=c++17" // C语言最新标准为c11,或根据自己的需要进行修改 ], // 编译命令参数 "type": "shell", // 可以为shell或process,前者相当于先打开shell再输入命令,后者是直接运行命令 "group": { "kind": "build", "isDefault": true // 设为false可做到一个tasks.json配置多个编译指令,需要自己修改本文件,我这里不多提 }, "presentation": { "echo": true, "reveal": "always", // 在“终端”中显示编译信息的策略,可以为always,silent,never。具体参见VSC的文档 "focus": false, // 设为true后可以使执行task时焦点聚集在终端,但对编译c和c++来说,设为true没有意义 "panel": "shared" // 不同的文件的编译信息共享一个终端面板 } // "problemMatcher":" fileBasenameNoExtension.exe","g",//"Wall",//"staticlibgcc",//"fcolordiagnostics",//clanggcc"target=x8664w64mingw",//clangtargetmsvcLinux"std=c++17"//Cc11],//"type":"shell",//shellprocessshell"group":"kind":"build","isDefault":true//falsetasks.json,"presentation":"echo":true,"reveal":"always",//alwayssilentneverVSC"focus":false,//true使taskcc++true"panel":"shared"////"problemMatcher":"gcc” // 如果你不使用clang,去掉前面的注释符,并在上一条之后加个逗号。照着我的教程做的不需要改(也可以把这行删去)
}
]
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值