#if 0用法和 #if 1 用法
#if 1
......
#endif
#if 0
......
#endif
因为没有用过,感到有点莫名。如是上网查找答案。终于明白是用来注释编译内容的。意思是说:
#if 1 需要编译器编译以下内容;
#if 0 编译器不要编译以下内容;
#if 0 #endif 这种用法还可以实现“注释嵌套!!!”
例如:
void Time_Display(u32 TimeVar)
{
#if 1
u32 TY = 0, TM = 1, TD = 0;
s32 Num4Y,NumY, OffSec, Off4Y = 0;
u32 i;
s32 NumDay; //OffDay;
#endif
u32 THH = 0, TMM = 0, TSS = 0;
#if 0
THH = TimeVar/3600;
TMM = (TimeVar % 3600)/60;
TSS = (TimeVar % 3600)% 60;
#endif
#if 1
{
Num4Y = TimeVar/SecsPerFourYear;
OffSec = TimeVar%SecsPerFourYear;
i=1;
while(OffSec > Year_Secs_Accu[i++])
Off4Y++;
NumY = Num4Y*4 + Off4Y;
TY = 2000+NumY;
OffSec = OffSec - Year_Secs_Accu[i-2];
i=0;
if(TY%4)
{ // common year
while(OffSec > Month_Secs_Accu_C[i++]);
TM = i-1;
OffSec = OffSec - Month_Secs_Accu_C[i-2];
}
else
{ // leap year
while(OffSec > Month_Secs_Accu_L[i++]);
TM = i-1;
OffSec = OffSec - Month_Secs_Accu_L[i-2];
}
NumDay = OffSec/SecsPerDay;
OffSec = OffSec%SecsPerDay;
TD = NumDay+1;
THH = OffSec/3600;
TMM = (OffSec % 3600)/60;
TSS = (OffSec % 3600)% 60;
}
#endif
printf("Date: %0.4d-%0.2d-%0.2d Time: %0.2d:%0.2d:%0.2dr",TY, TM, TD,THH, TMM, TSS);
}
if 相关文章:
- Linux下Sniffer程序的实现(06-12)
- DSP核信号采集系统通讯接口设计(05-13)
- 用FIFO实现DSP间的双向并行异步通讯(08-15)
- 基于智能手机的校园短信网关系统的设计与实现(10-05)
- TMS320C672x系列浮点DSP的EMIF研究与应用(02-18)
- 异步FIFO在FPGA与DSP通信中的运用 (03-22)