关于vscode配置C/C++的配置文件问题

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "D:\\code\\MinGW\\bin\\g++.exe",
            "cStandard": "gnu17",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "windows-gcc-x64"
        }
    ],
    "version": 4
}

launch.json

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe - 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\code\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe 生成活动文件 ver(1)"
        }
    ]
}

settings.json

{
    "C_Cpp.errorSquiggles": "Disabled",
    "files.associations": {
        "ostream": "cpp",
        "iostream": "cpp",
        "random": "cpp"
    }
}

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe 生成活动文件",
            "command": "D:\\code\\MinGW\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${workspaceFolder}/build/${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "编译器: D:\\code\\MinGW\\bin\\g++.exe"
        },
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe 生成活动文件 ver(1)",
            "command": "D:\\code\\MinGW\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${workspaceFolder}/build/${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ]
}

在vscode选择打开的文件夹下新建一个build文件夹,可以把exe文件都放到里面,更加美观。

如果使用code runner,在它的设置中找到settings.json文件进行修改,如下

{
    "code-runner.executorMap":
        {
        "cpp": "cd $dir && g++ -std=c++11 $fileName -D LOCAL -o D:/code/C++/build/$fileNameWithoutExt.exe && D:/code/C++/build/$fileNameWithoutExt.exe"
        },//增添的的部分!!!路径改成自己建立的build文件夹,比如D:/code/C++/build(自己替换)
    "code-runner.runInTerminal": true,
    "code-runner.ignoreSelection": true,
    "c-cpp-compile-run.run-in-external-terminal": true,
    "workbench.iconTheme": "eq-material-theme-icons-palenight",
    "editor.fontSize": 18,
    "workbench.colorTheme": "Community Material Theme Palenight",
    "files.autoSave": "afterDelay",
    "extensions.ignoreRecommendations": true,
    "editor.hover.enabled": false,
    "editor.parameterHints.enabled": false,
    "terminal.integrated.scrollback": 1600,
    "bracket-pair-colorizer-2.depreciation-notice": false,
    "window.zoomLevel": 1
    
    
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值