• VScode编写调试C/C++程序(详细整理)


     复制如下命令:

    {
       "version": "0.2.0",
       "configurations": [
           {
               "name": "C++ Launch (GDB)",                
               "type": "cppdbg",                         
               "request": "launch",                        
               "targetArchitecture": "x86",                
               "program": "${workspaceRoot}\\${fileBasename}.exe",                 
               "miDebuggerPath":"D:\\mingw64\\bin\\gdb.exe", 
               "args": [],     
               "stopAtEntry": false,                  
               "cwd": "${workspaceRoot}",                  
               "externalConsole": true,                  
               "preLaunchTask": "g++"                    
               }
       ]
    }

    【注意】:这里根据自己的文件安装目录进行更改:

    5.创建一个tasks.json的配置文件

    复制如下命令:

    {
        "version": "0.1.0",
        "command": "g++",
        "args": ["-g","-std=c++11","${file}","-o","${workspaceRoot}\\${fileBasename}.exe"],
        "problemMatcher": {
            "owner": "cpp",
            "fileLocation": ["relative", "${workspaceRoot}"],
            "pattern": {
                "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                "file": 1,
                "line": 2,
                "column": 3,
                "severity": 4,
                "message": 5
            }
        }
    }

    6.创建一个c_cpp_properties.json文件

    并复制如下命令:

    {
        "configurations": [
            {
                "name": "Win32",
                "includePath": [
                    "${workspaceRoot}",
                    "D:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++",
                    "D:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32",
                    "D:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward",
                    "D:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include",
                    "D:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/tr1",
                    "D:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include"
                ],
                "defines": [
                    "_DEBUG",
                    "UNICODE",
                    "__GNUC__=6",
                    "__cdecl=__attribute__((__cdecl__))"
                ],
                "intelliSenseMode": "msvc-x64",
                "browse": {
                    "path": [
                        "${workspaceRoot}",
                    "D:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++",
                    "D:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32",
                    "D:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward",
                    "D:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include",
                    "D:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/tr1",
                    "D:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include"
                    ]
                },
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        ],
        "version": 3
    }

    【注意】:这里同样根据自己的文件安装目录进行更改:

    7.新建一个test.cpp文件,并点击左侧的调试按钮

    五、运行

    然后,我们点击左侧的运行按钮,

     

  • 相关阅读:
    (二)ABP+MetroNic--- 用户管理及角色管理的实现
    BootstrapValidator 自定义服务端验证
    ASP.Net Web API 的参数绑定[翻译]
    ABP webapi IDInput传参
    JqueryTable ServerSide Ajax 数据加载及样式设置
    JqueryTable踩过的坑
    Lambda 表达式中 动态解析OrderbyLinQ语句的实现
    jenkins问题整理
    maven profile实现多环境配置
    Spring 发送内嵌图片的邮件 遇到的问题
  • 原文地址:https://www.cnblogs.com/lishanyang/p/16002415.html
Copyright © 2020-2023  润新知