Vscode構築c++環境ファイル構成

4071 ワード

Vscodeはc++環境を構築して、半日振り回して、まずMinGWをダウンロードして環境変数を配置して、cmdの中でg+--versionを入力して成功するかどうかを見て、次に最も重要なのは.vscodeの下のいくつかのファイルは、このいくつかのファイルに半日かかりました.
  • c_cpp_properties.jaon
  • launch.json
  • tasks.json

  • c_cpp_properties.jaon
    {
        "configurations": [
            {
                "name": "Win32",
                "browse": {
                    "path": [
                        "${workspaceFolder}",
                        "C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++" //    c++    
                    ],
                    "limitSymbolsToIncludedHeaders": true
                },
                "includePath": [
                    "${workspaceFolder}",
                    "C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++" //    c++    ,  
                ],
                "defines": [
                    "_DEBUG",
                    "UNICODE",
                    "_UNICODE"
                ],
                "compilerPath": "C:\\MinGW\\bin\\gcc.exe", //    gcc.exe  
                "cStandard": "c11",
                "cppStandard": "c++14",
                "intelliSenseMode": "clang-x64"
            }
        ],
        "version": 4
    }
    

    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": "(gdb) Launch",
                "type": "cppdbg",
                "request": "launch",
                "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
                "args": [],
                "stopAtEntry": false,
                "cwd": "${workspaceFolder}",
                "environment": [],
                "externalConsole": true,
                "MIMode": "gdb",
                "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe", //   gdb.exe  
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ],
                "preLaunchTask": "Compile",
            }
        ]
    }
    

    tasks.jaon
    {
        // See https://go.microsoft.com/fwlink/?LinkId=733558
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "tasks": [
            {
                "label": "Compile", // launch.json  "preLaunchTask"   
                "type": "shell",
                "command": "g++",
                "args": [
                            "-g","${file}","-o","${fileDirname}/${fileBasenameNoExtension}.exe",
                        ],  
                "presentation": {
                    "reveal": "always",
                    "panel": "shared",
                    "focus": false,
                    "echo": true
                },
                "group": {
                    "kind": "build",
                    "isDefault": true
                },
                "problemMatcher": {
                    "owner": "cpp",
                    "fileLocation": "absolute",
                    "pattern": {
                        "regexp": "^(.*):(\\d+):(\\d+):\\s+(error):\\s+(.*)$",
                        "file": 1,
                        "line": 2,
                        "column": 3,
                        "severity": 4,
                        "message": 5
                    }
                }
            }
      ]
    }