VsCode Task/Launch配置文件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VsCode Task/Launch配置文件相关的知识,希望对你有一定的参考价值。
参考技术A 部分配置参数首先在Debug/Run中创建一个.vscode文件.
https://www.jianshu.com/p/ba6f4740c746
我是做一个TCP Server和Client的通信,下面是我的文件树
tasks.json
launch.json
还有一种是makefile运行
因为我不会makefile,所以就把makefile都放在src下了,本来需要分成release/build什么的,有空研究一下makefile怎么写.文件树中的c_cpp_properties.json不需要.
makefile
tasks.json
launch.json
主要是理解compunds的使用
可以一起run也可以分开run
参考
https://blog.csdn.net/leon_zeng0/article/details/107438624
vscode 配置
目录
一、C++配置
1.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": "g++.exe - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "$fileDirname\\\\$fileBasenameNoExtension.exe",
"args": [],
"stopAtEntry": false,
"cwd": "$workspaceFolder",
"environment": [],
"externalConsole": true, //注意此处如果不为true,不会有黑色弹窗
"MIMode": "gdb",
"miDebuggerPath": "D:\\\\mingw64\\\\bin\\\\gdb.exe", //你的mingw路径
"setupCommands": [
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
],
"preLaunchTask": "g++" //修改此项
]
1.2、tasks.json
"version": "2.0.0",
"tasks": [
"type": "shell",
"label": "g++", //同 luanch.json "preLaunchTask" 配置一样
"command": "D:\\\\mingw64\\\\bin\\\\g++.exe",
"args": [
"-g",
"$file",
"-o",
"$fileDirname\\\\$fileBasenameNoExtension.exe"
],
"options":
"cwd": "$workspaceFolder"
,
"problemMatcher": [
"$gcc"
],
"group": "build"
]
1.3、cs.cpp
#include <iostream>
using namespace std;
void mult(int num)
int i, j;
for (i = 1; i <= num; ++i)
for (j = i; j <= num; ++j)
cout << i << " * " << j << " = " << i * j << "\\t";
cout << endl;
int main(void)
int num =9;
mult(num);
system("pause");
return 0;
二、C语言配置
1、test.c
#include "stdio.h"
void main()
printf("\\n Hello world \\n");
system("pause");
1.2、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": "gcc.exe - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "$fileDirname\\\\$fileBasenameNoExtension.exe",
"args": [],
"stopAtEntry": false,
"cwd": "$fileDirname",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "D:\\\\mingw64\\\\bin\\\\gdb.exe",
"setupCommands": [
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
],
"preLaunchTask": "gcc"
]
1.3、tasks.json
"tasks": [
"type": "cppbuild",
"label": "gcc",
"command": "D:\\\\mingw64\\\\bin\\\\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"$file",
"-o",
"$fileDirname\\\\$fileBasenameNoExtension.exe"
],
"options":
"cwd": "$fileDirname"
,
"problemMatcher": [
"$gcc"
],
"group":
"kind": "build",
"isDefault": true
,
"detail": "调试器生成的任务。"
],
"version": "2.0.0"
注意:调试程序时,需要返回到主函数页面,在点击程序执行按钮
以上是关于VsCode Task/Launch配置文件的主要内容,如果未能解决你的问题,请参考以下文章
ubuntu下vscode调试c++怎么配置launch.json和task.json