当前位置:网站首页>Vscode three configuration files about C language

Vscode three configuration files about C language

2022-07-07 17:38:00 Larry Chow

stay cmd.exe Enter the following command :
gcc -v -E -x c++ -

When used vscode Open folder , Automatically created .vscode Folder , In this folder , establish 3 Configuration files , Namely c_cpp_properties.json、launch.json、tasks.json.

Put the information in the red box in the configuration file , Replace .

stay c_cpp_properties.json in

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceRoot}",
                "D:/programFiles/MinGW/include/**",
                "D:/programFiles/MinGW/bin/../lib/gcc/mingw32/6.3.0/include/c++",
                "D:/programFiles/MinGW/bin/../lib/gcc/mingw32/6.3.0/include/c++/mingw32",
                "D:/programFiles/MinGW/bin/../lib/gcc/mingw32/6.3.0/include/c++/backward",
                "D:/programFiles/MinGW/bin/../lib/gcc/mingw32/6.3.0/include",
                "D:/programFiles/MinGW/bin/../lib/gcc/mingw32/6.3.0/../../../../include",
                "D:/programFiles/MinGW/bin/../lib/gcc/mingw32/6.3.0/include-fixed"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "__GNUC__=6",
                "__cdecl=__attribute__((__cdecl__))"
            ],
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": "",
                "path": [
                    "${workspaceRoot}",
                    "D:/programFiles/MinGW/include/**",
                    "D:/programFiles/MinGW/bin/../lib/gcc/mingw32/6.3.0/include/c++",
                    "D:/programFiles/MinGW/bin/../lib/gcc/mingw32/6.3.0/include/c++/mingw32",
                    "D:/programFiles/MinGW/bin/../lib/gcc/mingw32/6.3.0/include/c++/backward",
                    "D:/programFiles/MinGW/bin/../lib/gcc/mingw32/6.3.0/include",
                    "D:/programFiles/MinGW/bin/../lib/gcc/mingw32/6.3.0/../../../../include",
                    "D:/programFiles/MinGW/bin/../lib/gcc/mingw32/6.3.0/include-fixed"
                ]
            }
        }
    ],
    "version": 4
}

stay launch.json in

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "cmd",
            "preLaunchTask": "echo",
            "args": [
                "/C",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "&",
                "echo.",
                "&",
                "pause"
            ],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole":true
        },
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\Program Files\\mingw64\\bin\\gdb.exe",//  My own computer gdb
            "preLaunchTask": "echo",// Here and task.json Of label Corresponding 
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
 
        }
    ]
}

stay tasks.json in :

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "gcc",
            "args": [
                "-g", 
                "${file}", 
                "-o", 
                "${fileBasenameNoExtension}.exe",
                "-fexec-charset=GBK"// Solve the Chinese garbled code 
            ]
        }
    ],
    "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "shared", 
        "showReuseMessage": true,
        "clear": false
    }
}

原网站

版权声明
本文为[Larry Chow]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071524421912.html