microsoft / microsoft/vscode-cpptools

It is not debugging c++ files but it works fine with c files

Offen
#7,981 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

debugger
Vorherrschende Sprache
TypeScript
Sterne
6.2k
Forks
1.7k
Ø Merge
14 Std. 46 Min.
Gemergte PRs (30 T.)
61

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit den im Bericht gezeigten .vscode/launch.json- und tasks.json-Konfigurationen und reproduziere anschließend das Debuggen einer neuen .cpp-Datei unter Windows mit der C/C++ extension. Vergleiche die Referenz auf die Pre-Launch-Task mit der definierten Task und überprüfe, dass der Build abgeschlossen ist, bevor das Debugging beginnt; abgeschlossen bedeutet, dass die Beispiel-C++-Datei ohne den gemeldeten Exit-Code-Fehler gebaut und unter dem Debugger gestartet wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp, vscode
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.