VSCode installation, vscode compiler, vscode adding an external header .h files, vscode terminal does not flash back, mingw, vscode configuration C ++

1.mingw posix seh

链接:https://pan.baidu.com/s/1w_EIYDU7ro5TiseiBySmAA 
提取码:epi9

2.mingw configure the environment variables
3. Create a folder
4.vscode opening
5. Create a new file .cpp

#include <stdio.h>
#include <windows.h>
int main()
{
 printf("Hello World\n");
 system("pause");
 return 0;
}

6.F5
7.gdb, G ++
8. The annotated mouse placed
launch.json

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

task.json

{
// 有关 tasks.json 格式的文档,请参见
    // https://go.microsoft.com/fwlink/?LinkId=733558
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "g++.exe build active file",
            "command": "F:\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-I",//外部头文件
                "C:/Users/PH/Desktop/c++primer",//外部头文件
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "F:\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\\mingw64\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        }
    ]
}

10.ctrl + shift + p, enter "the Configuration"
c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:/Users/PH/Desktop/c++primer"//外部头文件
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.18362.0",
            "compilerPath": "F:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",//C++标准
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 4
}

Modify the terminal does not flash back
Launch.json

 "externalConsole": false,
Published 19 original articles · won praise 0 · Views 1255

Guess you like

Origin blog.csdn.net/qq_35459198/article/details/105282530