1 define
2 ifdef 条件编译
3 extern 变量申明
3.1 对结构体
在.h文件中 进行结构体定义
typedef struct
{
uint8_t RTC_Hours; /*!< Specifies the RTC Time Hour.
This parameter must be set to a value in the 0-12 range
if the RTC_HourFormat_12 is selected or 0-23 range if
the RTC_HourFormat_24 is selected. */
uint8_t RTC_Minutes; /*!< Specifies the RTC Time Minutes.
This parameter must be set to a value in the 0-59 range. */
uint8_t RTC_Seconds; /*!< Specifies the RTC Time Seconds.
This parameter must be set to a value in the 0-59 range. */
uint8_t RTC_H12; /*!< Specifies the RTC AM/PM Time.
This parameter can be a value of @ref RTC_AM_PM_Definitions */
}RTC_TimeTypeDef;
在.c文件中进行定义:
RTC_TimeTypeDef RTC_time_current;
在其它要用的地方申明:
extern RTC_TimeTypeDef RTC_time_current;
3.2对变量
在.c 文件中进行定义
u8 state=0;
在用的地方进行声明
extern u8 state;
4 typedef 类型别名
5 结构体
6 static
static u8 flag = 0;
定义后 仅限本.c文件内使用flag 且仅仅执行一次