VScode C语言配置文件

记录一下vscode的配置文件

1. windows

要安装MinGW
1). launch.json

{
    "configurations": [
    {
        "name": "(gdb) Launch",
        "type": "cppdbg",
        "request": "launch",
        "program": "${fileDirname}\\build\\${fileBasenameNoExtension}.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${fileDirname}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "miDebuggerPath": "C:\\Program Files (x86)\\mingw64\\bin\\gdb.exe",
        "preLaunchTask": "C/C++: g++.exe build active file",// 和tasks.json里面的label一致
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            },
            {
                "description": "Set Disassembly Flavor to Intel",
                "text": "-gdb-set disassembly-flavor intel",
                "ignoreFailures": true
            }
        ]
    }
    ]
}

2). tasks.json

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "cppbuild",
			"label": "C/C++: g++.exe build active file",
			"command": "C:\\Program Files (x86)\\mingw64\\bin\\g++.exe",
			"args": [
				"-fdiagnostics-color=always",
				"-g",
				//"-D_USE_32BIT_TIME_T",
				//"${fileDirname}\\*.cpp",
				"${fileDirname}\\*.c",
				"-pthread",
				"-fexec-charset=GBK",//防止乱码
				//"${file}",
				"-lz",
				"-o",
				"${fileDirname}\\build\\${fileBasenameNoExtension}.exe"
			],
			"options": {
				"cwd": "${fileDirname}"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": "build",
			"detail": "compiler: \"C:\\Program Files (x86)\\mingw64\\bin\\g++.exe\""
		}
	]
}

2. remote linux

1). launch.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":"myexe : makefile build and debug",    
            "type":"cppdbg",        
            "request":"launch",    
            "program":"${fileDirname}/${fileBasenameNoExtension}",    //执行这个文件,相当于命令行中输入这行
            "args":[],    
            "stopAtEntry":false,    //大概是表示是否在main函数处停下,类似在main上打断点。
            "cwd":"${workspaceRoot}",    //表示在哪个目录下执行program,相当于命令行中输入cd 该行
            "environment":[],            
            "MIMode":"gdb",           
            "miDebuggerPath":"/usr/bin/gdb",    //调试工具的路径
            "preLaunchTask": "C/C++: gcc build active file",
            "setupCommands":[    
                {
                    "description":"Enable pretty-printing for gdb",    
                    "text":"-enable-pretty-printing",        //gdb下执行的命令,启用整齐打印,就是让gdb打印的东西好看一点。
                    "ignoreFailures":true        
                },
                {
                    "description":"Let User defined signal 1 not appear",
                    "text":"handle SIGUSR1 nostop noprint",    
                    "ignoreFailures":true       
                }
            ],
            //"internalConsoleoptions":"openOnSessionstart",   
        }
    ]
    
}

2). tasks.json

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc build active file",
            "command": "/usr/bin/gcc",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${fileDirname}/*.c",
                "-lpthread",
                "-lz",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}
  • 9
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值