avr-gcc-list
[Top][All Lists]
Advanced

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

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


From: Heike C. Zimmerer
Subject: [avr-gcc-list] Re: __DATE__ constant, any way to format it differently ?
Date: Thu, 29 Jan 2009 10:56:47 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

"Anton James Erasmus" <address@hidden> writes:

> You can use the following MACROS and functions to get the
> values in integer format. You can then display the date and
> time in whatever format you desire.
>
> #define COMPILE_HOUR (((__TIME__[0]-'0')*10) +
> (__TIME__[1]-'0'))
> #define COMPILE_MINUTE (((__TIME__[3]-'0')*10) +
> (__TIME__[4]-'0'))
> #define COMPILE_SECOND (((__TIME__[6]-'0')*10) +
> (__TIME__[7]-'0'))

is __TIME__ guaranteed not to change between invocations?  Else you may
end up at 1:00:00 where 1:59:59 would have been appropriate.


> unsigned char GetCompileHour(void)
> {
>   unsigned char hour=COMPILE_HOUR;
>   return(hour);
> }
> [...]

This all happens in the AVR where space is tight.  I prefer a small
shell script which prepares a .h file containing all constants (date,
build #, hardware revision, etc) in their final representation.






reply via email to

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