配置vscode 编译运行调试c/c++

1 篇文章 0 订阅
1 篇文章 0 订阅
  • 配置vscode 编译 运行 调试 C/C++
  • Visual Studio Code
  • Astyle 规范代码格式
  • 少数英语不影响阅读,转自自己的博客
  • 需要根据自己机器不同,修改四五行json文件名(主要为路径

Visual Studio Code

Frist step:download vscode and basic modules

download
home
- Astyle
- C/C++
- Code Runner
- Python
- Markdown All in one

Second step:get Mingw and Astyle binary file

download page

Third step:initilzation Configuration to reach c/c++’s bulid`run and debug
launch.json

{  
    "version": "0.2.0",  
    "configurations": [  

        {  
            "name": "(gdb) Launch", 
            "type": "cppdbg",       
            "request": "launch",   
            "program": "${workspaceRoot}/${fileBasenameNoExtension}.exe",
            "args": [],             
            "stopAtEntry": false,     
            "cwd": "${workspaceRoot}",
            "environment": [],  
            "externalConsole": true, 
            "MIMode": "gdb",  
            "miDebuggerPath": "C:\\mingw64\\bin\\gdb.exe", 
            "preLaunchTask": "g++",  
            "setupCommands": [  
                {   
                    "description": "Enable pretty-printing for gdb",  
                    "text": "-enable-pretty-printing",  
                    "ignoreFailures": true  
                }  
            ]  
        }  
    ]  
}

tasks.json

{  
    "version": "2.0.0",  
    "command": "g++",  
    "args": ["-g","${file}","-o","${workspaceRoot}/${fileBasenameNoExtension}.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  
        }  
    }  
}  

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "/usr/include",
                "/usr/local/include",
                "${workspaceFolder}"
            ],
            "defines": [],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "/usr/include",
                    "/usr/local/include",
                    "${workspaceFolder}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "macFrameworkPath": [
                "/System/Library/Frameworks",
                "/Library/Frameworks"
            ]
        },
        {
            "name": "Linux",
            "includePath": [
                "/usr/include",
                "/usr/local/include",
                "${workspaceFolder}"
            ],
            "defines": [],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "/usr/include",
                    "/usr/local/include",
                    "${workspaceFolder}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        },
        {
            "name": "Win32",
            "includePath": [
                "C:/mingw64/include/*",
                "C:/mingw64/include/gdb/*",
                "C:/mingw64/include/libiberty/*"

            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "path": [
                    "${workspaceFolder}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ],
    "version": 3
}
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值