C语言求教:#ifndef __KEY_H__的作用

[复制链接]
5833|3
 楼主| fabest 发表于 2008-2-22 13:29 | 显示全部楼层 |阅读模式
如下例:
#ifndef __KEY_H__
#define __KEY_H__

#include "at89x52.h"
#include "my_type.h"

extern volatile uint8 idata KeyCurrent,KeyOld,KeyNoChangedTime;
extern volatile uint8 idata KeyPress;
extern volatile uint8 idata KeyDown,KeyUp,KeyLast;

extern volatile uint8 KeyCanChange;

void InitKeyboard(void);

#define KeyIO P1

#define KEY1 0x01
#define KEY2 0x02
#define KEY3 0x04
#define KEY4 0x08
#define KEY5 0x10
#define KEY6 0x20
#define KEY7 0x40
#define KEY8 0x80

#endif


上面的COPY computer00的一个头文件,不知道#ifndef __KEY_H__ #define __KEY_H__   #endif 这三个语句是什么意思,平时在做头文件的时候,我没写这几个语句程序也没有问题。不知有何区别??

  不好意思,让大家见笑了,我C语言学得不好,请大家不吝赐教,感谢了。。
孤星119 发表于 2008-2-22 14:00 | 显示全部楼层

防止重复编译.

ayb_ice 发表于 2008-2-22 15:18 | 显示全部楼层

这是C的预处理

作用很大,还是要搞懂的。。。
huangqi412 发表于 2008-2-22 15:31 | 显示全部楼层

基本c常识

您需要登录后才可以回帖 登录 | 注册

本版积分规则

28

主题

174

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部