[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Code version timestamp
From: |
Anton Erasmus |
Subject: |
Re: [avr-gcc-list] Code version timestamp |
Date: |
Wed, 14 Sep 2005 22:25:54 +0200 |
On 14 Sep 2005 at 6:21, John Altstadt wrote:
> address@hidden wrote:
> > Dear All,
> >
> > I would like to display a "code version" (date/time or incremental
> > number) during init on an LCD display. Does anybody know if there is
> > any information in the executable (ROM file) that I can use at
> > runtime (updated by the linker for example) ?
> >
> > If no, does anybody know how to implement this ?
> > I was thinking to generate an asm code using a script in the make,
> > but seems to be complicated.
> >
> > Thanks for your suggestions.
> > Eric.
>
> Look at the __DATE__ and __TIME__ predefined macros. Since they are
> already string constants, you can use the compiler to concatenate them
> with the string you want to display, such as:
>
> char *version =
> "Compiled on " __DATE__ " at " __TIME__;
>
> Put this line by itself in a file called version.c, and then change
> the appropriate Makefile target to remove version.o as the last step,
> e.g.:
>
> %.elf: $(OBJ)
> @echo
> @echo $(MSG_LINKING) $@
> $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
> rm version.o
There is a better way to force the recompile of version.c
Add the following at the end of your makefile
# Always compile version.c to get correct compilation date and time
.PHONY: version.c
[Snipped]
Regards
Anton Erasmus
--
A J Erasmus