VSCODE C++配置 Windows/Win10

有什么问题可以留言的,我会的我就回答一下咯~

暂时写这么多,有点乱,有空再更新,看起来可能有点费劲

我这是windows的配置哦~mac的和linux的仅供参考啦~

首先呢~自己创建一个文件夹为cpp的工作目录, 相关cpp都在以下工作目录进行啦.

主要是那个.vscode那个文件夹下的文件, 他有相关的操作可以逐一生成,改天再更新相关操作啦

你也可以直接自己创建文件夹,不需要根据相关操作来.

新建好文件夹后, 通过单击菜单-文件-打开文件夹即可再相应目录下进行编辑了,F5即可运行

如果文件都复制了还不可以,试试把注释去掉

下面是 c_cpp_properties.json

注意哦:

“includePath”那里是你对应的MinGW里的头文件目录哦,如果你电脑里有codeblock或者vc++的话,相应的目录里面也有MinGW,也是可以使用的,我这个是单独另外下载安装的,如有需要请另行百度MinGW安装教程,其实安装MinGW挺麻烦的,直接安装个codeblock比较方便。

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "D:\\Program Files\\MinGW\\include\\*",
                "D:\\Program Files\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\*",
                "D:\\Program Files\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++\\*",
                "D:\\Program Files\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++\\mingw32\\*",
                "D:\\Program Files\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++\\bits\\*"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "path": [
                    "${workspaceFolder}",
                    "D:\\Program Files\\MinGW\\include\\*",
                    "D:\\Program Files\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\*",
                    "D:\\Program Files\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++\\*",
                    "D:\\Program Files\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++\\mingw32\\*",
                    "D:\\Program Files\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++\\bits\\*"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}

下面是launch.json

注意:"miDebuggerPath": "D:\\Program Files\\MinGW\\bin\\gdb.exe",

这个也是MinGW目录里的啦。

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "preLaunchTask": "build",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,    //true的话, F5编译运行后会暂停, 需要自己再操作继续运行, 看个人习惯
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\Program Files\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }]
}

下面是settings.json

{
    "C_Cpp.intelliSenseEngineFallback": "Disabled",
    "files.associations": {
        "iostream": "cpp",
        "string": "cpp",
        "stack": "cpp",
        "fstream": "cpp",
        "vector": "cpp",
        "[cpp]": {
            "editor.quickSuggestions": true
                },
            "[c]": {
            "editor.quickSuggestions": true
                }
    },
    "files.autoGuessEncoding": true,
    "C_Cpp.errorSquiggles": "Disabled",
    "editor.detectIndentation": false,
}

下面是tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared"
            },
            "windows": {
                "command": "g++",
                "args": [
                    "-ggdb",
                    "\"${file}\"",
                    "--std=c++11",
                    "-o",
                    "\"${fileDirname}\\${fileBasenameNoExtension}.exe\""
                ]
            }
        }
    ]
}

最后,别忘了配置环境变量path。

posted @ 2018-05-16 11:29  碧殇冰心  阅读(10373)  评论(0编辑  收藏  举报