错误提示如上所述。我们使用工具默认生成的launch.json文件如下:

{"configurations": [{"name": "C/C++: g++.exe 生成和调试活动文件","type": "cppdbg","request": "launch","program": "${fileDirname}\\${fileBasenameNoExtension}.exe","args": [],"stopAtEntry": false,"cwd": "${fileDirname}","environment": [],"externalConsole": false,"MIMode": "gdb","miDebuggerPath": "D:\\software\\mingw64\\bin\\gdb.exe",//按照位置自己改“\\的原因是\与转义符含义冲突,故采用/或\\”"setupCommands": [{"description": "为 gdb 启用整齐打印","text": "-enable-pretty-printing","ignoreFailures": true},{"description": "将反汇编风格设置为 Intel","text": "-gdb-set disassembly-flavor intel","ignoreFailures": true}],"preLaunchTask": "C/C++: g++.exe 生成活动文件"}],"version": "2.0.0"}

生成的tasks.json文件如下:

{"tasks": [{"type": "cppbuild","label": "C/C++: g++.exe 生成活动文件","command": "D:\\software\\mingw64\\bin\\g++.exe",//需要更改"args": ["-fdiagnostics-color=always","-g","${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe"],"options": {"cwd": "${fileDirname}"},"problemMatcher": ["$gcc"],"group": "build","detail": "调试器生成的任务。"}],"version": "2.0.0"}

在这里容易发生的问题:

1、task文件的label与launch文件的preLaunchTask需要一致;

2、task文件的type值要改成shell!!!!!

在这里出问题的根本原因其实是对于各个语句的不熟悉,在出现莫名错误时候,建议找到别人的配置文件跑一下,如果可以运行,就一句一句改成自己的,直到排除错误。我就是这样发现错误的。

相同错误有人说要把编译器放到C盘,实验失败。最后表明无影响。根源还是配置文件有些项目写错了,需要借鉴排除错误。

vscode简要安装过程及注意点见VScode安装包的设置,安装中简要流程及遇到的问题汇总C/C++_� 翠的博客-CSDN博客

VScode中c语言编写多个C文件见

VScode中c语言编写多个C文件_vscode 编译多个c文件_� 翠的博客-CSDN博客