Bootstrap

visual studio code配置

看过好多博主写的文章,按照他们的配置配置几乎都会报错,不排除我自身系统的问题,经过我多次调整,在其他博主json文件的基础上整改出一套符合自身系统的json文件。

仅供参考:

注:4个.json都需在.vscode的文件夹下,详情见其他博主。

VCS的插件功能使其灵活性非常高,例如这个我们可以利用“json”和"Path Intellisense"等插件辅助操作。

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "MinGW",
            "intelliSenseMode": "clang-x64",
            "compilerPath": "D:/LLVM/lib/clang/bin/gcc.exe",//这个根据自己电脑选择,无论哪个路径最终必须精确到gcc.exe
            "includePath": [
                "${workspaceFolder}"
            ],
            "defines": [],
            "browse": {
                "path": [
                    "${workspaceFolder}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}

launch.json

{
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "(gdb) Launch",
            "type": "cppdbg", 
            "request": "launch", 
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe", 
            "args": [], 
            "stopAtEntry": false, 
            "cwd": "${workspaceFolder}", 
            "environment": [], 
            "externalConsole": true, 
            "internalConsoleOptions": "neverOpen", 
            "MIMode": "gdb", 
            "miDebuggerPath": "gdb.exe", 
            "setupCommands": [
                { 
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": false
                }
            ],
            "preLaunchTask": "Compile" 
        }
    ]
}

settings.json

{
    "files.defaultLanguage": "c", 
    "editor.formatOnType": true, 
    "editor.suggest.snippetsPreventQuickSuggestions": false, 
    "editor.acceptSuggestionOnEnter": "off", 
    "code-runner.runInTerminal": true, 
    "code-runner.executorMap": {
        "c": "cd $dir && gcc '$fileName' -o '$fileNameWithoutExt.exe' -Wall -g -O2 -static-libgcc -std=c11 && &'$dir$fileNameWithoutExt'",//如有错误注意下这条
        "cpp": "cd $dir && g++ '$fileName' -o '$fileNameWithoutExt.exe' -Wall -g -O2 -static-libgcc -std=c++17 && &'$dir$fileNameWithoutExt'"//同上
    }, 
    "code-runner.saveFileBeforeRun": true, 
    "code-runner.preserveFocus": true, 
    "code-runner.clearPreviousOutput": false, 
    "code-runner.ignoreSelection": true, 

    "C_Cpp.clang_format_sortIncludes": true, 
    "C_Cpp.autocomplete": "Disabled", 
    "C_Cpp.suggestSnippets": false, 
}

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Compile", 
            "command": "gcc", 
            "args": [
                "${file}",
                "-o", 
                "${fileDirname}/${fileBasenameNoExtension}.exe",
                "-g", 
                "-Wall", 
                "-static-libgcc", 
            ], 
            "type": "process", 
            "group": {
                "kind": "build",
                "isDefault": true 
            },
            "presentation": {
                "echo": true,
                "reveal": "always", 
                "focus": false,
                "panel": "shared" 
            },
        }
    ]
}
;