vscode用dev配置c/c++

您所在的位置:网站首页 devc++环境 vscode用dev配置c/c++

vscode用dev配置c/c++

2024-07-07 06:52| 来源: 网络整理| 查看: 265

三步利用dev-cpp配置c/c++环境

1.、dev 找到devc 集成的mingw路径,添加环境变量(cmd输入gcc -v检测环境是否添加) 通常为: C:\Program Files (x86)\Dev-Cpp\MinGW64\bin 2、vs code 需要扩展:C/C++; code runner ; 插件c/c++ 插件code runner

3、配置 自定义文件夹.vscode 创立launch.json、tasks.json、c_cpp_properties.json三个文件 ● launch.json

{{ "version": "0.2.0", "configurations": [ { "name": "(gdb) 启动", "type": "cppdbg", "request": "launch", "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": false, "cwd": "${fileDirname}",//指默认文件操作的目录(如fopen的默认寻找位置),现在是c文件的目录,修改为${workspaceFolder}就是工作文件夹目录 "environment": [], "externalConsole": true, "MIMode": "gdb", "miDebuggerPath": "C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/gdb.exe",//路径要修改 "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "C/C++: gcc.exe 生成活动文件" } ] }}

● tasks.json

{ "version": "2.0.0", "command": "gcc", "args": [ "-g", "${file}", "-o", "${file}.exe" ], // 编译命令参数 "problemMatcher": { "owner": "cpp", "fileLocation": [ "relative", "${workspaceRoot}" ], "pattern": { "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 } }, "presentation": { "echo": true, "reveal": "always", "focus": false, "panel": "new", "showReuseMessage": true, "clear": false }, "tasks": [ { "type": "cppbuild", "label": "C/C++: gcc.exe 生成活动文件", "command": "C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/gcc.exe",//路径要修改 "args": [ "-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe" ], "options": { "cwd": "C:/Program Files (x86)/Dev-Cpp/MinGW64/bin"//路径要修改 }, "problemMatcher": [ "$gcc" ], "group": "build", "detail": "编译器: \"C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/gcc.exe"//路径要修改 } ] }

● c_cpp_properties.json

{ "configurations": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/**", "C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++", "C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/x86_64-w64-mingw32", "C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/backward", "C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/include", "C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../include", "C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/include-fixed", "C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/include" //路径要修改 ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "compilerPath": "C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/gcc.exe",//路径要修改 "cStandard": "c99", "cppStandard": "c++98", "intelliSenseMode": "gcc-x64" } ], "version": 4 } 注:代码来自知乎 3BPM


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3