曾今在IAR中这样用过:
/**
* 以下这些宏用于将编译器时间 Mmm dd yyyy hh:mm:ss 转变成 YYMMDDhhmmss 格式
*/
#define SM(o,s,m) (((o)[0] == (s)[0]) && ((o)[1] == (s)[1]) && (o)[2] == (s)[2]) ? m
#define STRM_TO_BCD(s) SM("Jan",s,0x01) : SM("Feb",s,0x02) : SM("Mar",s,0x03) : SM("Apr",s,0x04) :\
SM("May",s,0x05) : SM("Jun",s,0x06) : SM("Jul",s,0x07) : SM("Aug",s,0x08) :\
SM("Sep",s,0x09) : SM("Oct",s,0x10) : SM("Nov",s,0x11) : SM("Dec",s,0x12) : '?'
#define COMPILE_YEAR STR_TO_BCD(__DATE__ + 9)
#define COMPILE_MON STRM_TO_BCD(__DATE__+ 0)
#define COMPILE_DAY STR_TO_BCD(__DATE__ + 4)
#define COMPILE_HOUR STR_TO_BCD(__TIME__ + 0)
#define COMPILE_MIN STR_TO_BCD(__TIME__ + 3)
#define COMPILE_SEC STR_TO_BCD(__TIME__ + 6)
#define COMPILE_TIME COMPILE_SEC,COMPILE_MIN,COMPILE_HOUR,COMPILE_DAY,COMPILE_MON,COMPILE_YEAR
|