Windows10でVisual studio code(v1.41.1)でCのコンパイルとデバッグがしたいのですが、C/C++のextensionと入れて、コンパイルするとexeファイルは生成されるのですが、実行してもOUTPUTに何も表示されません。
MinGWはインストール済みでパスが通っていることも確認しています。
mingw32-base
mingw32-gcc-g++
コンパイルしたソースファイルとlaunch.jsonとtask.jsonは下記になるのですが、何か間違えていたら教えて頂けないでしょうか?
(追記)
launch.jasonの下記部分を修正すると、デバッグは出来るようになりました。
(前)"program": "${workspaceFolder}/sample.exe",
(後)"program": "${workspaceFolder}/.vscode/sample.exe",
ただ、VSCODEのOUTPUTに何も出力されません。。
c
1#sample.c 2#include <stdio.h> 3int main(void) 4{ 5 int a = 2; 6 int b = 3; 7 int c; 8 9 c = a + b; 10 11 printf("c(%d) = a(%d) + b(%d) \n", c, a, b); 12 13 return 0; 14}
json
1#launch.json 2{ 3 // Use IntelliSense to learn about possible attributes. 4 // Hover to view descriptions of existing attributes. 5 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 6 "version": "0.2.0", 7 "configurations": [ 8 { 9 "name": "(gdb) Launch", 10 "type": "cppdbg", 11 "request": "launch", 12 "program": "${workspaceFolder}/sample.exe", 13 "args": [], 14 "stopAtEntry": false, 15 "cwd": "${workspaceFolder}", 16 "environment": [], 17 "externalConsole": false, 18 "MIMode": "gdb", 19 "miDebuggerPath": "C:\MinGW\bin\gdb.exe", 20 "setupCommands": [ 21 { 22 "description": "Enable pretty-printing for gdb", 23 "text": "-enable-pretty-printing", 24 "ignoreFailures": true 25 } 26 ] 27 } 28 ] 29}
json
1#task.json 2{ 3 // See https://go.microsoft.com/fwlink/?LinkId=733558 4 // for the documentation about the tasks.json format 5 "version": "2.0.0", 6 "tasks": [ 7 { 8 "type": "shell", 9 "label": "gcc.exe build active file", 10 "command": "C:\MinGW\bin\gcc.exe", 11 "args": [ 12 "-g", 13 "${file}", 14 "-o", 15 "${fileDirname}\${fileBasenameNoExtension}.exe" 16 ], 17 "options": { 18 "cwd": "C:\MinGW\bin" 19 }, 20 "problemMatcher": [ 21 "$gcc" 22 ], 23 "group": { 24 "kind": "build", 25 "isDefault": true 26 } 27 } 28 ] 29}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/01/16 03:15