[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
<>1.生成可执行程序的过程
在C/CPP中,生成可执行程序需要经过预处理、编译、汇编、链接四个过程
<>1.1预处理
预处理阶段:
* 展开头文件、宏替换、条件编译、去掉注释
* 生成.i文件
<>1.2编译
* 检查语法
* 生成汇编代码
* 生成.s文件
<>1.3汇编
汇编阶段:
* 将汇编代码转化为二进制机器码
* 生成该文件的符号表
* 生成.o文件
<>1.4链接
链接:
* 合并段表
* 汇总符号表,找调用函数的地址,链接对应上,合并到一起
* 将所有的.o文件和静态库、动态库链接在一起生成可执行程序
<>2.CPP的处理
为什么cpp支持函数重载而c语言不支持函数重载?
通过可执行文件的生成过程我们知道,我们知道在汇编过程中,符号表里面会记录函数名和函数地址的映射关系。
//以下面的简单程序为例 void f(int a,double b) { printf("%d %f",a,b); } void f(double b,
int a) { printf("%f %d",b,a); }
查看函数对应的符号表
可以总结出cpp汇编中的函数名为:
Z 函数名长度 函数名 参数类型首字母1,首字母2…
<>3.C语言的处理
//以下面的程序为例 void f(int a,int b) { printf("%d %d",a,b); } void func(int c,int d)
{ printf("%d %d",c,d); }
查看符号表
C语言中符号表中,函数的地址同样是和函数名进行对应,但是C语言中符号表的函数名没有包含参数类型,函数名长度的信息。
这也解释了C语言为什么不支持函数重载。因为当相同的函数名被定义的时候,汇总符号表时就发生了错误。所以这类错误发生在函数的汇编阶段
<>4.CPP函数重载的类型
符号表中,函数名和地址一一对应。而CPP符号表中函数名是由:Z 函数名长度 函数名 参数类型首字母1,首字母2…
所以函数重载的类型有:
* 函数的参数;类型不同
* 函数参数的顺序不同
* 函数参数的个数不同