vscode C语言环境配置

1.安装VScode
2.安装插件
vscode安装c插件
3.下载gcc
MinGW
大概50M左右,11几M的那个不好不能用
4.将文件解压放到相应的位置,然后将bin文件的目录放置到环境变量,这样就可以在terminal中调用bin中的gcc,gdb等文件。
5.在终端输入gcc -v
安装正确时的输出
6.现在就可以通过终端编译文件了

	gcc -g test.c -o test.exe

	./test

7.配置debug
自己在当前工程下面创建.vscode文件夹,并在其下放置launch.json和tasks.json两个文件夹。
(当没创建时,调用debug会自动创建)

配置文件

主要配置launch.json,tasks.json文件

{
    // 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": "gcc.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\2_professional\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "gcc.exe build active file"
        }
    ]
}
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "gcc.exe build active file",
            "command": "D:\\2_professional\\mingw64\\bin\\gcc.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "D:\\2_professional\\mingw64\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        }
    ]
}

**debug时,调用launch文件执行gdb.exe,当发现没有可执行文件,则调用tasks文件执行gcc.exe,对文件进行编译,生成可执行文件。

launch.json中的 “preLaunchTask”: “gcc.exe build active file” 和 tasks.json中的"label": "gcc.exe build active file"要一样,前者才会调用后者。

launch.json中的 “externalConsole”: true, 默认是false要改为true。这样终端才会调出来。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值