1. 程式人生 > >IAR開發STM8,如何加入每次編譯的日期時間資訊來做為版本資訊

IAR開發STM8,如何加入每次編譯的日期時間資訊來做為版本資訊

IAR開發STM8,如何加入每次編譯的日期時間資訊來做為版本資訊呢??

網上找打了這個:

--------

IAR USING PRE- AND POST-BUILD ACTIONS


Using pre-build actions for time stamping


If necessary, you can specify pre-build and post-build actions that you want to occur before or after the build. 


The Build Actions dialog box—available from the Project menu—lets you specify the actions required.
For more information about the Build Actions dialog box, see Build actions options, page 215.


Using pre-build actions for time stamping


You can use pre-build actions to embed a time stamp for the build in the resulting binary file. Follow these steps:
1 Create a dedicated time stamp file, for example, timestamp.c and add it to your project.
2 In this source file, use the preprocessor macros __TIME__ and __DATE__

to initialize a string variable.
3 Choose Project>Options>Build Actions to open the Build Actions dialog box.
4 In the Pre-build command line text field, specify for example this pre-build action:


cmd /c "del "$OBJ_DIR$\timestamp.o""


在網上找了半天,終於找到了,

http://blog.chinaunix.net/uid-30127490-id-5062415.html

IAR的巨集定義:


const char MenuStr[]={"T1xxxxxxxxxxP-xxE##"__DATE__"#####"};  //定義字串常量