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

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

Visual Studio Code

Frist step:download vscode and basic modules

download
配置vscode 编译运行调试c/c++_第1张图片
- 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
}

你可能感兴趣的:(acm,c/c++,vscode)