From: a7yvm109gf5d1 on
Hello
Back when I was doing assembler on the 8051, I used some compiler
specific labels to include the date and time of compilation in a
string. The microcontroller could then send out this information on
request.

I hope this is the right NG for this question. I am now using Winavr
and avr-gcc. I haven't done any coding in years.

How could I do this now?

Just to be specific, I am *not* asking for the Atmel to give me the
_current_ date and time, I just want a string in flash with the
compilation date and time of the code.

TIA
From: Stef on
In comp.arch.embedded,
a7yvm109gf5d1(a)netzero.com <a7yvm109gf5d1(a)netzero.com> wrote:
> Hello
> Back when I was doing assembler on the 8051, I used some compiler
> specific labels to include the date and time of compilation in a
> string. The microcontroller could then send out this information on
> request.
>
> I hope this is the right NG for this question. I am now using Winavr
> and avr-gcc. I haven't done any coding in years.
>
> How could I do this now?
>
> Just to be specific, I am *not* asking for the Atmel to give me the
> _current_ date and time, I just want a string in flash with the
> compilation date and time of the code.


Most compilers provide the predifined macros __DATE__ and __TIME__ for
that purpose.


--
Stef (remove caps, dashes and .invalid from e-mail address to reply by mail)

In this world there are only two tragedies. One is not getting what one
wants, and the other is getting it.
-- Oscar Wilde
From: Chris Giese on
a7yvm109gf5d1(a)netzero.com wrote:

>Hello
>Back when I was doing assembler on the 8051, I used some compiler
>specific labels to include the date and time of compilation in a
>string. The microcontroller could then send out this information on
>request.
>
>How could I do this now?


#include <stdio.h>
int main(void) { printf("I was compiled on %s\n", __DATE__); return 0; }

From: a7yvm109gf5d1 on
On Apr 6, 7:50 pm, NoEmail...(a)execpc.com (Chris Giese) wrote:
> a7yvm109gf...(a)netzero.com wrote:
> >Hello
> >Back when I was doing assembler on the 8051, I used some compiler
> >specific labels to include the date and time of compilation in a
> >string. The microcontroller could then send out this information on
> >request.
>
> >How could I do this now?
>
> #include <stdio.h>
> int main(void) { printf("I was compiled on %s\n", __DATE__); return 0; }

I'm tickled pink by this, thanks.
Was I searching for the wrong term, "timestamp"? This info didn't
exactly pop out at me.
From: Tim Wescott on
a7yvm109gf5d1(a)netzero.com wrote:
> On Apr 6, 7:50 pm, NoEmail...(a)execpc.com (Chris Giese) wrote:
>> a7yvm109gf...(a)netzero.com wrote:
>>> Hello
>>> Back when I was doing assembler on the 8051, I used some compiler
>>> specific labels to include the date and time of compilation in a
>>> string. The microcontroller could then send out this information on
>>> request.
>>> How could I do this now?
>> #include <stdio.h>
>> int main(void) { printf("I was compiled on %s\n", __DATE__); return 0; }
>
> I'm tickled pink by this, thanks.
> Was I searching for the wrong term, "timestamp"? This info didn't
> exactly pop out at me.

Apparently!

Note #1: __TIME__ and __DATE__ are part of the ANSI C standard; while
I'm sure there are compilers that don't support them, I haven't run into
one.

Note #2: If you are interested in version control, one of the things
that you want is for a 'production' build for a particular version of
software to come out bit-exact each and every time. You want this,
because five years down the road when some Very Important Customer wants
Just One Change, or if you have to track down some Dread Bug, it is
exceedingly soothing to be able to verify that you can, indeed, check
out and rebuild some hex file that's going into production hardware.

This rules out using time and date stamping _on production builds_. My
preferred process is to have a "version" header or source file that gets
changed to match the version, and which takes a "development code" flag
that tells it to insert compile time and date instead.

--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com
 |  Next  |  Last
Pages: 1 2
Prev: Named RTOS objects
Next: Faster image rotation