vscode的c配置求助,鱼币答谢
我用从网上找了关于vscode配置环境的教程,tasks.json,launch.json如下我也没找出什么问题
然后每次一调试就会出现如下报错
好像是c没有编译成功,请各位大佬指点一下 {
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",//测试文件地址
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,//在内部或外部运行
"MIMode": "gdb",
"miDebuggerPath": "D:/minGW/mingw64/bin/gdb.exe",//编译器gdb地址
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe build active file"
},
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: gcc.exe build active file",
"command": "D:/minGW/mingw64/bin/gcc.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
直接复制就行了(应该没什么问题) https://zhuanlan.zhihu.com/p/147366852 °蓝鲤歌蓝 发表于 2021-2-5 17:07
能不能从我的图片上指出错误,我按这个文章改了之后仍有错误提示 https://fishc.com.cn/forum.php?mod=viewthread&tid=188396
参考一下 xxm8023 发表于 2021-2-5 17:43
https://fishc.com.cn/forum.php?mod=viewthread&tid=188396
参考一下
能不能帮忙看一下我的launch.json和tasks.json写的哪里有问题
我主要是因为这个没调试成功 能否把两个文件的内容发一下, 这样也方便调试并找出问题 PC_ 发表于 2021-2-5 18:09
能否把两个文件的内容发一下, 这样也方便调试并找出问题
test2.c:
#include<stdio.h>
#include<limits.h>
int main(){
printf("int 内存大小 : %lu \n",sizeof(int));
return 0;
}
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: gcc.exe build active file",
"command": "gcc",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
launch.json:
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",//测试文件地址
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,//在内部或外部运行
"MIMode": "gdb",
"miDebuggerPath": "D:/minGW/mingw64/bin/gdb.exe",//编译器gdb地址
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}, {
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: gcc.exe build active file",
"command": "gcc", //这里改成你gcc的具体路径, D:/minGW/mingw64/bin/gcc.exe
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
group那里需要加:
"group": {
"kind": "build",
"isDefault": true
}
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",//测试文件地址
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,//在内部或外部运行
"MIMode": "gdb",
"miDebuggerPath": "D:/minGW/mingw64/bin/gdb.exe",//编译器gdb地址
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
在这个文件后面加,
"preLaunchTask": "C/C++: gcc.exe build active file"
(直接复制到那个后面就行了) PC_ 发表于 2021-2-5 18:40
group那里需要加:
谢谢,把 "preLaunchTask": "C/C++: gcc.exe build active file"这一行加到tasks.json上就能用了
页:
[1]