compile information into static array

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

compile information into static array

617件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Gonzalo_Sipel on Wed Aug 20 06:48:40 MST 2014
Hello,
I was wondering if there is any way to store or save some code information into my compiled code. I would like to use date of compilation to initialize a constant variable. Is there any macro which allow me to do that? I'm looking for a way to save automatically date of compilation or code version to be able to show it in my LCD device.
Thanks.
0 件の賞賛
返信
2 返答(返信)

604件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Gonzalo_Sipel on Thu Aug 21 04:29:51 MST 2014
rocketdawg,
                    Thank you for the information,I found it very useful!
0 件の賞賛
返信

604件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rocketdawg on Wed Aug 20 11:37:28 MST 2014
The C language has such a construct.
it is called "const"
it is considered good form to declare the type T and then add the modifier "const"
T const variableName

unsigned int const LCDVersion = 5;
unsigned char const Title[] = "Greatest Application";
similar to these are the __DATE__, __TIME__, __FUNCTION__, __FILE__, __LINE__, ...
these are pre-processor defines in GCC.  If you are using another compiler, you will have to check that they work.
printf("%s\n", __DATE__);

so something like
unsigned char const BuildDate[] = __DATE__;  // might work for you, if I have the types correct

Dan Saks http://www.dansaks.com/articles.htm has some useful articles about const.
also see http://www.embedded.com/




0 件の賞賛
返信