Topic: Project build date and time


Author: Robert Klemme <klemme@unity.de>
Date: 1999/09/03
Raw View
David R Tribble schrieb:
> =

> But you could write a C/C++ program which generates standard C/C++
> code containing, say, an embedded string with the time and date,
> then compile the output source and link in the resulting object
> file.

i'd prefer a shell script - much simpler.

 robert

-- =

Robert Klemme
Internet Consultant/Berater
-------------------------------------------------------------
UNITY AG ~ Riemekestra=DFe 160 ~ D-33106 Paderborn
http://www.unity.de ~ E-Mail: mailto:klemme@unity.de
Telefon: 0 52 51 / 6 90 90-207 ~ Fax: 0 52 51 / 6 90 90-199
-------------------------------------------------------------
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: David R Tribble <david@tribble.com>
Date: 1999/09/07
Raw View
Robert Klemme wrote:
>
> David R Tribble schrieb:
> >
> > But you could write a C/C++ program which generates standard C/C++
> > code containing, say, an embedded string with the time and date,
> > then compile the output source and link in the resulting object
> > file.
>
> i'd prefer a shell script - much simpler.

We use C/C++ programs because they are more portable than shell
scripts.

-- David R. Tribble, david@tribble.com --
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: David R Tribble <david@tribble.com>
Date: 1999/08/30
Raw View
Scott Robert Ladd wrote:
>
> Walid Ismail wrote:
> > __TIME__ and __DATE__ are will get updated only if the file
> > containing them has changed. I there any macros that are project
> > dependent ?.
>
> No, because the concept of "project" is outside the scope of Standard
> C++.  The Standard defines a language, and not an implementation; the
> date and time a project is compiled is part of the implementation.

It's worth noting that some compilers/systems do generate such
information, or allow the programmer to specify such information.
AT&T Unix compilers used to support a '#version' directive, for
example, and Win32 IDEs allow the programmer to define a "version
resource" that gets compiled into the executable.  But none of
this is addressed by the ISO C or C++ standards; these all qualify
as "compiler extensions".

But you could write a C/C++ program which generates standard C/C++
code containing, say, an embedded string with the time and date,
then compile the output source and link in the resulting object
file.  Your executable will then contain an embedded string with
the date and time that the build was performed.  We use something
similar where I work for all of our programs and libraries.  It's
fairly straightforward to add this rule to your makefiles.  (This
approach is very similar to the revision identification strings
supplied by RCS and SCCS that can be embedded in your source files.)

-- David R. Tribble, david@tribble.com --


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: wwww2000@my-deja.com
Date: 1999/08/29
Raw View
Is there anyway I can get a c/c++ project build date and time using
standard c/c++ ?.
I am developing an application on multiple platforms, so i need this to
be independent of the enviroment.

__TIME__ and __DATE__ are will get updated only if the file containing
them has changed. I there any macros that are project dependent ?.

thanks,
Walid Ismail


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: clamage@eng.sun.com (Steve Clamage)
Date: 1999/08/30
Raw View
wwww2000@my-deja.com writes:

>Is there anyway I can get a c/c++ project build date and time using
>standard c/c++ ?.
>I am developing an application on multiple platforms, so i need this to
>be independent of the enviroment.

>__TIME__ and __DATE__ are will get updated only if the file containing
>them has changed. I there any macros that are project dependent ?.

They give you the time and date that the file was compiled ("time
of translation" according to the standard), not the time it was
last edited.

You could create a special file version.cc, something like
    extern const char* Version = "Build of " __TIME__ " " __DATE__ ;
and compile it as part of each build.

--
Steve Clamage, stephen.clamage@sun.com
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Francis Glassborow <francis@robinton.demon.co.uk>
Date: 1999/08/30
Raw View
In article <7qasdn$ken$1@nnrp1.deja.com>, wwww2000@my-deja.com writes
>__TIME__ and __DATE__ are will get updated only if the file containing
>them has changed. I there any macros that are project dependent ?.

So make your build process 'touch' the file containing main.  Or
forcibly rebuild the project.


Francis Glassborow      Journal Editor, Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA          +44(0)1865 246490
All opinions are mine and do not represent those of any organisation


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: "Scott Robert Ladd" <scott@coyotegulch.com>
Date: 1999/08/30
Raw View
Walid Ismail wrote:
> __TIME__ and __DATE__ are will get updated only if the file containing
> them has changed. I there any macros that are project dependent ?.

No, because the concept of "project" is outside the scope of Standard C++.
The Standard defines a language, and not an implementation; the date and
time a project is compiled is part of the implementation.

--
  *     Scott Robert Ladd
  *
  *     Coyote Gulch Productions - http://www.coyotegulch.com
  *     GameLore - http://www.gamelore.com





[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]