标签:c程序 bin pac uil item png exe shell extension
1、程序路径不能有中文,因为MinGW不支持
2、选择一个文件夹当作工作区,并且在该文件夹下创建./vscode文件夹,并在该文件夹下创建两个json文件
launch.json
{ "version": "0.2.0", "configurations": [ { "name": "C/C++", "type": "cppdbg", "request": "launch", "program": "${fileDirname}/${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, //弹出黑框使用true,不弹出使用false "MIMode": "gdb", "miDebuggerPath": "D:/MinGW/bin/gdb.exe", //选择gbd.exe的绝对路径 "preLaunchTask": "compile", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], }, ] }
tasks.json
{ "version": "2.0.0", "tasks": [ { "type": "shell", "label": "compile", "command": "gcc", //c文件就用gcc,cpp文件就用g++ "args": [ "-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe" ], "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true } } ] }
题外话:
如果想让vscode运行向dev-c++一样出现黑框的话,需要安装C/C++ Compile Run插件
除此之外,需要将设置-扩展-Compile Run configuration中找到如下选项进行勾选,使用F6运行
标签:c程序 bin pac uil item png exe shell extension
原文地址:https://www.cnblogs.com/dongshuaishuai/p/13179239.html