add timestamp during compile

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

add timestamp during compile

434 次查看
jfannon
Contributor I

Hello,

 

I am looking for a way to include a timestamp in the code that I compile.  I want to assign an address in flash of say 4 bytes and put the date and time of compile into it automatically.(perhaps UTC time or some other format).  This way when I am looking at the firmware on a chip later I can determine when the code was compiled that is currently loaded.

 

Thank you for your help.

 

PS, I am programming a 9s08SH32 part if that makes any difference.

标签 (1)
0 项奖励
1 回复

273 次查看
kef
Specialist I

There are predefined standard C string constants __DATE__ and __TIME__. Usage is like

const char date[] = __DATE__;

 

Unfortunately you can't change format of these or encode them to long int or other more compact form.

0 项奖励