参考

https://www.cnblogs.com/lidabo/p/5888997.html

task有更新,不能使用文章的代码。

多文件

终端

touch main.c hw.c hw.h

vscode hw.c

Vscode

打开文件夹

编写三个项目文件

 /*hw.c*/
#include "hw.h" void print()
{
printf("Hello World!\n");
}
 /*hw.h*/
#include <stdio.h> void print();
 /*main.c*/
#include "hw.h" int main()
{
print(); return ;
}

此时使用

在终端直接使用gcc

gcc main.c hw.c hw.h

生成 a.out 和 hw.h.gch

使用make

在项目目录下建立makefile    touch makefile

编写makefile文件

build : main.o hw.o
gcc -o build main.o hw.o
main.o : main.c hw.h
gcc -g -c main.c
hw.o : hw.c hw.h
gcc -g -c hw.c
clean :
rm main.o hw.o

PS:clean下的代码需要使用 make clean 才调用

  -g :调试使用

  -c  :仅编译(Compile),不连接 (Make)

  -o :输出文件名

VS code 调试 配置

{
/*launch.json*/
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceFolder}/build",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
], "preLaunchTask": "make" //add } ]
}
{
/*task.json*/
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "make",
"type": "shell",
"command": "make",
"args": [] } ]
}

ctrl + shift + b 编译

设置断点

f5 开始调试

弹出终端 显示输出。

最新文章

  1. Constructing Roads——F
  2. UIButton 去除按下效果(阴影)
  3. 百度地图API 简单示例
  4. Oracle 中的 decode
  5. 1、Singleton 单件(创建模式)
  6. KMP算法总♂结
  7. JAVA JNI学习
  8. ORALCE 编译过程卡死解决方法。
  9. 不容忽略的——CSS规范
  10. .net 爬虫技术
  11. bzoj3160(FFT+回文自动机)
  12. 2017-12-14python全栈9期第一天第二节之初始计算机系统
  13. Android应用程序结构
  14. poj2228 Naptime【(环结构)线性DP】
  15. pyton unittest
  16. delphi简单单向字符串加密函数
  17. 使用cxf两个声明导致ObjectFactory 类中发生冲突
  18. [六字真言]5.咪.功力不足,学习前端JavaScript异常
  19. 好用的vim插件
  20. 【Codeforces】CF 165 E Compatible Numbers(状压dp)

热门文章

  1. 第三十二篇-NavigationView导航抽屉的使用
  2. ElasticSearch6.5.0【Java客户端之TransportClient】
  3. 免费馅饼 HDU - 1176 (动态规划)
  4. printf不定参数
  5. linux之awk命令获取最后一列
  6. weui的icons示例
  7. centos6.5mini版安装及配置
  8. TIMESTAMP使用遇到得麻烦
  9. 编写高质量Python代码总结:待完成
  10. bzoj千题计划311:bzoj5017: [Snoi2017]炸弹(线段树优化tarjan构图)