実現したいこと
VScode上でC++のプログラムをデバッグし、変数の値などを読み取りたい
前提
VScode上でC++を勉強しているのですが、ある問題を解いているときに配列の範囲外を指定してしまうエラーが発生しました。そこで、デバッグをして変数の値を読み取りミスを確認しようとしたのですが、エラーを吐いてできませんでした。一からワークスペースを作ることにして、サイトを参考にして構成したのですが、デバッグしようとすると「the value of midebuggerpath is invalid」のメッセージが出てデバッグできません。
発生している問題・エラーメッセージ
「the value of midebuggerpath is invalid」
該当のソースコード
C++
1#include <C:/bits/stdc++.h> 2using namespace std; 3 4int main(){ 5 int a=10; 6 for(int i=0;i<a;i++){ 7 cout << "Hello World" << endl; 8 } 9}
試したこと
サイトを真似して一から構成しました。
https://daily-tech.hatenablog.com/entry/2018/11/17/012113
https://dianxnao.com/vscode%EF%BC%9Agcc%E3%83%87%E3%83%90%E3%83%83%E3%82%AC%E3%82%A8%E3%83%A9%E3%83%BC%EF%BC%9Alaunch-program-does-not-exist-%E3%81%AE%E5%AF%BE%E5%87%A6%E6%B3%95/
自分はmingwをC:\pg\mingw64に入れているので、そこも変更しています。
補足情報
task.jsonの中身
C++
1{ 2 "version": "2.0.0", 3 "tasks": [ 4 { 5 "label": "echo", 6 "type": "shell", 7 "command": "g++", 8 "args":[ 9 "-g", "${file}", "-o", "${fileBasenameNoExtension}" 10 ], 11 "group":{ 12 "kind": "build", 13 "isDefault": true 14 } 15 } 16 ] 17}
c_cp_properties.jsonの中身
C++
1{ 2 "configurations": [ 3 { 4 "name": "Win32", 5 "includePath": [ 6 "${workspaceFolder}/include" 7 ], 8 "defines": [ 9 "_DEBUG", 10 "UNICODE", 11 "_UNICODE" 12 ], 13 "windowsSdkVersion": "10.0.22621.0", 14 "compilerPath": "cl.exe", 15 "cStandard": "c17", 16 "cppStandard": "c++17", 17 "intelliSenseMode": "windows-msvc-x64" 18 } 19 ], 20 "version": 4 21}
launch.jsonの中身
C++
1{ 2 // Use IntelliSense to learn about possible attributes. 3 // Hover to view descriptions of existing attributes. 4 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 "version": "0.2.0", 6 "configurations": [ 7 { 8 "name": "(gdb) Launch", 9 "type": "cppdbg", 10 "request": "launch", 11 "program": "${workspaceFolder}/src/sample.exe", 12 "args": [], 13 "stopAtEntry": false, 14 "cwd": "${workspaceFolder}", 15 "environment": [], 16 "externalConsole": true, 17 "MIMode": "gdb", 18 "miDebuggerPath": "C:\\pg\\MinGW\\bin\\gdb.exe", 19 "setupCommands": [ 20 { 21 "description": "Enable pretty-printing for gdb", 22 "text": "-enable-pretty-printing", 23 "ignoreFailures": true 24 } 25 ] 26 } 27 ] 28 }

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2024/06/13 14:41
2024/06/13 14:48
2024/06/13 14:50
2024/06/13 14:58
2024/06/13 15:12
2024/06/13 15:40
2024/06/13 16:02
2024/06/13 16:13
2024/06/13 16:15
2024/06/13 16:27
2024/06/13 16:42
2024/06/13 16:47
2024/06/13 16:49