VisualStudioCodeでリンク先の指示に従い環境構築を行いました。
「簡単にコンパイルできるようにする」の項目まで進め、実行ファイルを生成しました。
その後、「デバッガを使えるようにする」の項目まで行ったのですが、F5キーを押しても「Stopping due to fatal error: NullReferenceException: オブジェクト参照がオブジェクト インスタンスに設定されていません。」とデバッグコンソールに表示され、デバッグが実行できません。
どうすればデバッグの実行が可能になりますか。
test.cpp(デバッグしたいコード)
C++
1#include <bits/stdc++.h> 2using namespace std; 3int main(){ 4 printf("Hello,World!"); 5 printf("gcd of 252525 & 83025 is %d\n",__gcd(252525,83025)); 6 return 0; 7}
settings.json
json
1{ 2 "git.ignoreMissingGitWarning": true, 3 4 "C_Cpp.default.includePath": [ 5 "C:\MinGW\include", 6 "C:\MinGW\lib\gcc\mingw32\8.2.0\include\c++", 7 "C:\MinGW\lib\gcc\mingw32\8.2.0\include\c++\mingw32" 8 ], 9 "C_Cpp.default.compilerPath": "C:\MinGW\bin\g++.exe", 10 "C_Cpp.default.cppStandard": "c++14", 11 "C_Cpp.default.intelliSenseMode": "gcc-x64", 12}
tasks.json
json
1{ 2 // See https://go.microsoft.com/fwlink/?LinkId=733558 3 // for the documentation about the tasks.json format 4 "version": "2.0.0", 5 "tasks": [ 6 { 7 "label": "build", 8 "type": "shell", 9 "command": "g++", 10 "args": [ 11 "-std=gnu++1y", 12 "-g", 13 "-O2", 14 "${fileBasename}", 15 "-o", 16 "${fileBasenameNoExtension}.exe" 17 ], 18 "group": { 19 "kind": "build", 20 "isDefault": true 21 } 22 } 23 ] 24}
launch.json
json
1{ 2 // IntelliSense を使用して利用可能な属性を学べます。 3 // 既存の属性の説明をホバーして表示します。 4 // 詳細情報は次を確認してください: 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}/{fileBasenameNoExtension}.exe", 12 "args": [], 13 "stopAtEntry": false, 14 "cwd": "${workspaceFolder}", 15 "environment": [], 16 "externalConsole": true, 17 "MIMode": "gdb", 18 "miDebuggerPath": "C:\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}
状況
ターミナルからgdb ./test
として、デバッグを行うことはできます。F5でデバッグした場合のみエラーが出ます。
環境
Windows10
Visual Studio Code バージョン1.24.1
g++ v:
Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/8.2.0/lto-wrapper.exe Target: mingw32 Configured with: ../src/gcc-8.2.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --prefix=/mingw --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-8.2.0-3' --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --with-isl=/mingw --enable-libgomp --disable-libvtv --enable-nls --disable-build-format-warnings Thread model: win32 gcc version 8.2.0 (MinGW.org GCC-8.2.0-3)

回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。
2019/03/10 16:52