天天看點

VS code配置C/C++環境(Windows)VS code配置檔案

VS code配置檔案

VS code配置C/C++環境(Windows)VS code配置檔案

關于怎樣調出配置檔案,相信大家都有了解,不再贅述。

c_cpp_properties.json

關于怎樣檢視需要的TDM/Mingw路徑

VS code配置C/C++環境(Windows)VS code配置檔案
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                /*
                請将下面的路徑改為自己配置的TDM路徑,或者Mingw路徑 
                */
                "C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++",
                "C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/x86_64-w64-mingw32",
                "C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/backward",
                "C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/include",
                "C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../include",
                "C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/include-fixed",
                "C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "${workspaceRoot}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}
           

launch.json

// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team        
// ${file}: the current opened file                     
// ${fileBasename}: the current opened file's basename 
// ${fileDirname}: the current opened file's dirname    
// ${fileExtname}: the current opened file's extension  
// ${cwd}: the current working directory of the spawned process
{
    "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": "${file}.exe", // 将要進行調試的程式的路徑
        "miDebuggerPath": "C:\\TDM-GCC-64\\bin\\gdb.exe", // miDebugger的路徑,注意這裡要與MinGw的路徑對應,需要的是自己PC上配置的GDB路徑,主要是TDM/Mingw路徑
        "args": [""], // 程式調試時傳遞給程式的指令行參數,一般設為空即可
        "stopAtEntry": false, // 設為true時程式将暫停在程式入口處,一般設定為false
        "cwd": "${fileDirname}", // 調試程式時的工作目錄,一般為${workspaceRoot}即代碼所在目錄
        "externalConsole": true, // 調試時是否顯示控制台視窗,一般設定為true顯示控制台
        "preLaunchTask": "g++"   // 調試會話開始前執行的任務,一般為編譯程式,c++為g++, c為gcc
    }]
}
           

settings.json

{
    "files.associations": {
        "iostream": "cpp",
        "ostream": "cpp",
        "iosfwd": "cpp",
        "xlocale": "cpp",
        "xstring": "cpp",
        "istream": "cpp",
        "string": "cpp",
        "cmath": "cpp",
        "algorithm": "cpp",
        "limits": "cpp",
        "system_error": "cpp",
        "cstddef": "cpp",
        "cstdint": "cpp",
        "cstdio": "cpp",
        "cstdlib": "cpp",
        "cstring": "cpp",
        "ctime": "cpp",
        "cwchar": "cpp",
        "exception": "cpp",
        "initializer_list": "cpp",
        "iomanip": "cpp",
        "ios": "cpp",
        "new": "cpp",
        "stdexcept": "cpp",
        "streambuf": "cpp",
        "type_traits": "cpp",
        "typeinfo": "cpp",
        "utility": "cpp",
        "vector": "cpp",
        "xfacet": "cpp",
        "xiosbase": "cpp",
        "xlocinfo": "cpp",
        "xlocmon": "cpp",
        "xlocnum": "cpp",
        "xloctime": "cpp",
        "xmemory": "cpp",
        "xmemory0": "cpp",
        "xstddef": "cpp",
        "xtr1common": "cpp",
        "xutility": "cpp",
        "list": "c",
        "locale": "cpp",
        "xlocmes": "cpp",
        "regex": "cpp",
        "fstream": "cpp",
        "iterator": "cpp",
        "sstream": "cpp",
        "xlocbuf": "cpp",
        "deque": "cpp",
        "*.tcc": "cpp",
        "array": "cpp",
        "bitset": "cpp",
        "valarray": "cpp",
        "complex": "cpp",
        "forward_list": "cpp",
        "unordered_map": "cpp",
        "unordered_set": "cpp",
        "scoped_allocator": "cpp"
    },/*
    "python.unitTest.unittestArgs": [
        "-v",
        "-s",
        "./WorkGr",
        "-p",
        "test*.py"
    ],
    "python.unitTest.unittestEnabled": false,
    "python.unitTest.promptToConfigure": false,
    "python.unitTest.pyTestEnabled": false,
    "python.unitTest.nosetestsEnabled": false,
    "python.pythonPath": "C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37\\python.exe"*/
}
           

tasks.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","${file}.exe","-std=c++11"],    // 編譯指令參數
    "problemMatcher": {
        "owner": "cpp",
        "fileLocation": ["relative", "${workspaceRoot}"],
        "pattern": {
            "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "severity": 4,
            "message": 5
        }
    }
}