加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

有人有两次包含stdlib.h的原因吗?

发布时间:2020-12-16 10:13:15 所属栏目:百科 来源:网络整理
导读:我在这里研究Kilo文本编辑器的代码: https://github.com/antirez/kilo/blob/master/kilo.c 我注意到包括两次定义的stdlib.h(UPDATE:Comments is mine): #include termios.h#include stdlib.h // first time#include stdio.h #include errno.h#include str
我在这里研究Kilo文本编辑器的代码:

https://github.com/antirez/kilo/blob/master/kilo.c

我注意到包括两次定义的stdlib.h(UPDATE:Comments is mine):

#include <termios.h>
#include <stdlib.h> // first time
#include <stdio.h> 
#include <errno.h>
#include <string.h>
#include <stdlib.h>  // second time
#include <ctype.h>

这只是一个错误吗?或者有什么东西吗?我问,因为代码的作者似乎不是犯了很多错误的人.我不想暗示改变无知.

解决方法

由于stdlib.h有一个包含守卫,因此将它包括两次是没有意义的.可能错误是由两个文件合并引起的,两个文件都依赖于stdlib.h.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读