文章标题

来源:互联网 发布:seo搜索优化软件 编辑:程序博客网 时间:2024/06/01 10:28

文件main.c中:

include “test1.h”

include “test2.h”

文件test2.h中:

include “test1.h”

在test1.h中:

ifndef TEST1__H

define TEST1__H

endif

在main.c中第一次调用test1时,发现未定义就执行#ifndef - #endif之间的代码,之后调用test2时就不再定义test1了。
如果test1中有定义变量之类的,就会报重定义的错误。
作用:防止重复定义

0 0
原创粉丝点击