最近,我一直试图从CodeBlocks迁移到Visual代码,但后者给我带来了一些问题,特别是在使用类创建项目时,在本例中,当我试图运行它时,我得到了以下窗口:
preLaunchTask C/C++:G++..exe构建以退出代码-1结尾的活动文件
如果我单击“显示错误”,它会告诉我工作区中没有检测到问题。
然后单击“调试”之后,就会出现以下情况:
我已经有一段时间没有使用VScode了,但是我很确定启动程序是在第一次运行程序代码时创建的,对吗?
这是我的launch.json和task.json:
launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/myfile.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true
},
{
"name": "(Windows) Attach",
"type": "cppvsdbg",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "build myfile",
"type": "shell",
"command": "g++",
"args": [
"-std=c++14",
"-g",
"-o",
"myfile.exe",
"myfile.cpp"
],
"group": "build"
},
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\msys64\\mingw64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
]
}
对于类似的问题,我得到了所有的.json:https://stackoverflow.com/a/50658089/19009898,我以前有different.json,我猜这是默认的,但是这个更改似乎不会给之前没有类的其他代码带来任何麻烦,所以我想它是可以的。
会很感激你的帮助。
https://stackoverflow.com/questions/73186143
复制相似问题