VSCode 环境配置

网上很多教程,看着很详细。可是我照着做老是出问题。弄了好几天,今天早上又开始弄,终于配置好了。

launch.jason 里面的代码:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
           "type": "cppdbg",
            "request": "launch",
           "program": "${workspaceFolder}/a.out",  //此处修改,运行目录下编译后生成的a.out文件
           "args": [],
                  "stopAtEntry": false,
                  "cwd": "${workspaceFolder}",
                  "environment": [],
                  "externalConsole": true,
                  "MIMode": "gdb",
                  "preLaunchTask": "c_pre_build",    //添加此条,配置在运行前进行编译,引号中的名字随便取
        
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }]
         }
         
    ]
}

tasks.jason里面的代码:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label":"c_pre_build",//这里是launch.json中配置的preLaunchTask字段
            "command": "g++",
            "args": [
               "-g",
                "${file}"
            ]}
    ]
}

 

你可能感兴趣的:(C)