[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] __DATE__ constant, any way to format it differently ?

From: Steven Michalske
Subject: Re: [avr-gcc-list] __DATE__ constant, any way to format it differently ?
Date: Wed, 28 Jan 2009 16:12:17 -0800

CFLAGS+=" -DMY_DATE=`date +%y%m%d` "

and in your code

#ifndef MY_DATE
#error "MY_DATE not defined."

now use MY_DATE instead of __DATE__

or even better

-DMY_TIME=`date +%s`

this gives you the unix time stamp of seconds since 1970, you get time and date in 1 simple 32bit number that only takes up 4 bytes instead of a string. good if you use printf

you can also always adjust its epoch, or resolution,

/60 to get minutes /3600 for hours etc.
subtract the unix time of jan 1 2009 to get time since the new year

though these are not standard.


On Jan 28, 2009, at 1:30 PM, Vincent Trouilliez wrote:

On Wed, 28 Jan 2009 15:21:15 -0600
David Kelly <address@hidden> wrote:

OK, but if you don't commit the code to svn (as Vincent has stated in
other messages in this thread) then the svn version number is only "less
than or equal to" the real version number.

Yes that's why I give up on this :-/

I think if you don't like the format of __DATE__ then drop it into a
const during compile then pick out the parts you like when displaying.
Should be able to find them at constant offsets at run time.

Hey that's a nice idea, going to fiddle with that as soon as I hit the
Send button ! Thanks Dave.

The rule in the Makefile for the file containing __DATE__ needs to be an
"always build."

Oops, good remark, noted.


AVR-GCC-list mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]