VSCode+CygWin Windowsでlinuxプログラムを開発


インストールプロセス
先にCygWinをインストールします:ネット上で教程があって、主にboost gcc gdbをインストールします
VSCodeをインストールして環境を設定するには:https://blog.csdn.net/zjwengyidong/article/details/53789533
問題
しゅつりょくたんふごう
設定でrunInTerminalをTrueに設定し、端末を直接使用することができます.cmdの符号化とVSCodeの出力符号化が一致しないため、符号化が乱れていると推測されます.
VSCodeの実行とコンパイルエラー
私の設定を先に置いてJSON
launch.json

{
    //    IntelliSense       。 
    //             。
    //        ,   : https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [

        {
           "name": "C++ Launch (GDB)",                 //     ,               
            "type": "cppdbg",                           //     ,     cppdbg
            "request": "launch",                        //       ,   launch(  ) attach(  )
            "targetArchitecture": "x64",                //       ,   x86 x64,   x86, arm, arm64, mips, x64, amd64, x86_64
            "program": "${workspaceRoot}/${fileBasenameNoExtension}.exe",                   //             
            "miDebuggerPath":"g:/cygwin/bin/gdb.exe", // miDebugger   ,      cygwin/MinGw     
            "args": ["blackkitty",  "1221", "# #"],     //                 ,       
            "stopAtEntry": false,                       //   true            ,     false
            "cwd": "${workspaceRoot}",                  //           ,   ${workspaceRoot}       
            "externalConsole": true,                    //             ,     true     
            "preLaunchTask": "g++"
        }
    ]
}
task.json

{
   // See https://go.microsoft.com/fwlink/?LinkId=733558
   // for the documentation about the tasks.json format
   "version": "2.0.0",
   "command": "g++",
   "args": ["-g","${file}","-o","${fileBasenameNoExtension}.exe"],    //       
   "problemMatcher": {
       "owner": "cpp",
       "fileLocation": ["relative", "${workspaceRoot}"],
       "pattern": {
           "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
           "file": 1,
           "line": 2,
           "column": 3,
           "severity": 4,
           "message": 5
       }
   }
}

ここでは実行プロセスを理解する
1.最初の運転時はtaskのみが実行する.json taskがなければjsonはエラーが発生し、タスクを構成させ、構成が完了すると、jsonの構成に従ってプログラムをコンパイルします.
gccが間違っていることに注意してください.g++を使うのが一番いいです.パラメータの中で{file}がファイルを持っているパス、例えばtestです.cppはどのディスクのどのフォルダの下にあるか、{fileBasenameNoExtension}はなく、接尾辞もなくtestです.これは後ろにあるjsonでgdbデバッグにピットがあります.
2.デバッグの場合はlaunchに対応する.jsonプロセスでは、最後のオプションは実行するタスク、すなわち上のtaskであることに注意してください.jsonの流れは、taskを先に完了します.jsonプロセス、launchを完了します.jsonプロセスは、gdbデバッグを行うには、プログラムをコンパイルしてからでなければなりません.プログラムではプログラムパスに注意してください.