microsoft / microsoft/vscode-cpptools
It is not debugging c++ files but it works fine with c files
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Bug type: Debugger
Describe the bug
- OS and Version: windows 10
- VS Code Version: latest
- C/C++ Extension Version: latest
- Other extensions you installed (and if the issue persists after disabling them): code runner by jun han. and yes the issue is still there after disabling it.
- A clear and concise description of what the bug is. So the debugger in vs code is not allowing me to debug c++ files but i can debug c files, so i dont know what is the problem with it. I was able to debug c++ a few days ago but now i am not allowed to do so. Whenever i try to debug this message comes up : "the prelaunch task 'C/C++: g++.exe build active file' terminated with exit code -1".
To Reproduce
Please include a code sample and launch.json configuration.
Here is the code sample :
#include<bits/stdc++.h>
using namespace std;
int main(){
printf("hi");
return 0;
}
Here is the 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": "gcc.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe build active file"
}
]
}
Here is the task.json :
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "C:\MinGW\bin\gcc.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
Steps to reproduce the behavior:
just make a new file with the cpp extension. copy paste the code. click on debugging provided u have included these json files. and u can see the error.
Additional context
If applicable, please include logging by adding "logging": { "engineLogging": true, "trace": true, "traceResponse": true } in your launch.json
Add any other context about the problem here including log or error messages in your Debug Console or Output windows.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the .vscode/launch.json and tasks.json configurations shown in the report, then reproduce debugging a new .cpp file on Windows with the C/C++ extension. Compare the pre-launch task reference with the defined task and verify the build completes before debugging starts; done means the sample C++ file builds and launches under the debugger without the reported exit-code error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, vscode
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100