Linux(ubuntu)下配置VSCode中的C语言环境

C with VSCode on Linux

https://www.youtube.com/watch?v=9pjBseGfEPU

ps.C/C++版本不能太新,v1.8.2版本可自动生成完整的lauch.json文件

附我的.vscode文件夹下的代码文件

lauch.json文件

{
    "version": "0.2.0",
    "configurations": [
    
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/bin/${fileBasenameNoExtension}", // 把生成的.exe文件放在bin文件夹下,C文件所在的位置需有一个命名为bin的文件夹
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": true,// 打开外部terminal
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: gcc 生成活动文件"
        }
    ]
}

 tasks.json文件

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "cppbuild",
			"label": "C/C++: gcc 生成活动文件",
			"command": "/usr/bin/gcc",
			"args": [
				"-fdiagnostics-color=always",
				"-g",
				"${file}",
				//"example.c",//多文件编译的时候才需要
				"-o",
				"${fileDirname}/bin/${fileBasenameNoExtension}"
			],
			"options": {
				"cwd": "${fileDirname}"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": {
				"isDefault": true,
				"kind": "build"
			},
			"detail": "编译器: /usr/bin/gcc"
		}
	]
}

目录安排

 

 

posted @ 2022-10-20 20:47  iuhokin  阅读(656)  评论(0)    收藏  举报