VSCode C in the windows / C ++ environment configuration

Part from:

https://www.cnblogs.com/TAMING/p/8560253.html

https://www.cnblogs.com/TAMING/p/10147910.html

1. launch.json

We need to modify the place: Launch of "miDebuggerPath" option to set the location for your debugger (gdb.exe) here is MinGW installed on my computer's location -w64

Whether the installation is MinGW or mingw-w64, there will be a gdb.exe in the bin directory of the installation file folder, you must take the corresponding path correction or can not debug

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C/C++",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "D:/develop/mingw64/bin/gdb.exe",
            "preLaunchTask": "g++",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
        },
    ]
}
2. tasks.json
{
    "version": "2.0.0",
    "command": "g++",
    "args": [
        "-g",
        "${file}",
        "-o",
        "${fileDirname}/${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
        }
    },
    "group": {
        "kind": "build",
        "isDefault": true
    }
}

After opening .c / cpp file in the current workspace subdirectories you can add a breakpoint debugging

3. c_cpp_properties.json

If you can not find the file add the following configuration file

Among them, you want to change the option includePath lib under the installation path you mingw Compiler / gcc / x86_64-w64-mingw32 / 8.1.0 / include folder path

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "D:/develop/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

For non-standard library header files can also be added to the includePath path through the list of additional ways to

such as:

"includePath": [
                "C:/Program Files/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include",
          "path1",
          "path2",
          ...
],
4. The program runs under the terminal

And then click Open: File> Preferences> Settings> User settings> expand> Run Code Configuration

Run In Terminal tick find the program will run this operation on the terminal vscode

In the work area set also has this option, but the work zone setting will only take effect on the work area

Problems can not be entered in the terminal 5. runtime

The switch input method to the English model , an individual may only enter under the Chinese digital mode and then stuck.

6. common plug-ins
  • C/C++
  • C++ Intellisense
  • Code Runner
  • One Dark Pro
  • Bracket Pair Colorizer

Guess you like

Origin www.cnblogs.com/oaoa/p/11110982.html