Skip to content

IDE配置

📅 发表于 2018/02/11
🔄 更新于 2018/02/11
👁️ 次访问
📝 0 字
0 分钟
编辑器配置
#vscode

VSCode-CPP

vscode-cpp

使用vscode写cpp程序。参考自vscode-cpp知乎

1 下载安装vscode

2 下载安装MINGW

3 VSCode安装cc++官方扩展

4 配置json文件

c_cpp_properties.json, 编译环境

ctrl+shift+p ,选择edit configurations, 更新windows的配置

json
{
            "name": "Win32",
            "intelliSenseMode": "clang-x64",
            "includePath": [
                "${workspaceRoot}",
                "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++",
                "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/mingw32",
                "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/backward",
                "C:/MinGW/lib/gcc/mingw32/6.3.0/include",
                "C:/MinGW/include",
                "C:/MinGW/lib/gcc/mingw32/6.3.0/include-fixed"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "__GNUC__=6",
                "__cdecl=__attribute__((__cdecl__))"
            ],
            "browse": {
                "path": [
                    "C:/MinGW/lib/gcc/mingw32/6.3.0/include",
                    "C:/MinGW/lib/gcc/mingw32/6.3.0/include-fixed",
                    "C:/MinGW/include/*"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
}

launch.json, 执行结果文件。选择左边的调试ctrl+shift+d, 选择添加配置,选择gdbll什么的。粘贴下面的内容。

json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch (GDB)",                 // 配置名称,将会在启动配置的下拉菜单中显示
            "type": "cppdbg",                           // 配置类型,这里只能为cppdbg
            "request": "launch",                        // 请求配置类型,可以为launch(启动)或attach(附加)
            "targetArchitecture": "x86",                // 生成目标架构,一般为x86或x64,可以为x86, arm, arm64, mips, x64, amd64, x86_64
            "program": "${fileDirname}/${fileBasenameNoExtension}.out",                   // 将要进行调试的程序的路径
            "miDebuggerPath":"c:\\MinGW\\bin\\gdb.exe", // miDebugger的路径,注意这里要与MinGw的路径对应
            "args": [],                                 // 程序调试时传递给程序的命令行参数,一般设为空即可
            "stopAtEntry": false,                       // 设为true时程序将暂停在程序入口处,一般设置为false
            "cwd": "${workspaceRoot}",                  // 调试程序时的工作目录,一般为${workspaceRoot}即代码所在目录
            "externalConsole": true,                    // 调试时是否显示控制台窗口,一般设置为true显示控制台
            "preLaunchTask": "g++"                    // 调试会话开始前执行的任务,一般为编译程序,c++为g++, c为gcc
        }
    ]
}

tasks.json, 编译参数。F5运行调试代码, 选择配置任务,使用模板创建tasks文件,选择others。粘贴下面的内容。

json
{
    "version": "0.1.0",
    "command": "g++",
    "args": ["-g","${file}","-o","${fileDirname}/${fileBasenameNoExtension}.out", "-std=c++0x"],    // gcc编译命令参数
    "problemMatcher": {
        "owner": "cpp",
        "fileLocation": ["relative", "${workspaceRoot}"],
        "pattern": {
            "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "severity": 4,
            "message": 5
        }
    }
}
总访客数:   ·   总访问量:
PLM's Blog @ 2016 - 2025