469,623 Members | 1,971 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

Obtaining a Compilation Datestamp

To help users identify what version of my program they are using, I want it to have an "Identity string" available.

eg
"Prog: Bodgit, Version: 0.0.0, Compiled: 20061215"

The version number would be manually updated, but, just in case I forget, then I want the datestamp to be based on the datea and time the program was compiled/linked. Please can someone tell me whether there is a function available to return this information to me? Many thanks.
Dec 15 '06 #1
4 2026
To help users identify what version of my program they are using, I want it to have an "Identity string" available.

eg
"Prog: Bodgit, Version: 0.0.0, Compiled: 20061215"

The version number would be manually updated, but, just in case I forget, then I want the datestamp to be based on the datea and time the program was compiled/linked. Please can someone tell me whether there is a function available to return this information to me? Many thanks.
Hmm,

As far as i know there is no function in C to get this information. But dont you think this time stamp would be the time stamp at which the C executable was modified.. If it is may be your problem can narrow down to knowing a DOS command which will give us the time at which the executable file was last modified. Which inturn can be used in system function using C.

Regards,
ShaggY@FtF
Dec 15 '06 #2
Thanks for reply - Should have said Linux and G++. Am I right in thinking that there is only one date on a unix file and that by the time this gets FTP'd to the target machine it will have been modified and so not be the date/time when it was created?
Dec 15 '06 #3
Banfa
9,064 Expert Mod 8TB
eg
"Prog: Bodgit, Version: 0.0.0, Compiled: 20061215"
ANSI C/C++ contains some predefined macros as follows

__DATE__
The compilation date of the current source file. The date is a string literal of the form Mmm dd yyyy.

__FILE__
The name of the current source file. __FILE__ expands to a string surrounded by double quotation marks.

__LINE__
The line number in the current source file. The line number is a decimal integer constant.

__STDC__
Indicates full conformance with the ANSI C standard.

__TIME__
The most recent compilation time of the current source file. The time is a string literal of the form hh:mm:ss.

__TIMESTAMP__
The date and time of the last modification of the current source file, expressed as a string literal in the form Ddd Mmm Date hh:mm:ss yyyy, where Ddd is the abbreviated day of the week and Date is an integer from 1 to 31.


So you can achieve what you want with the string

Expand|Select|Wrap|Line Numbers
  1. "Prog: Bodgit, Version: 0.0.0, Compiled: " __DATE__
  2.  
Dec 15 '06 #4
Thank you for both replies. The second one gives me exactly the solution I hoped for - Mike
Dec 15 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Zee Zop | last post: by
reply views Thread by Lennart Hoglund | last post: by
8 posts views Thread by Daniele Baroncelli | last post: by
11 posts views Thread by seannakasone | last post: by
17 posts views Thread by Phil M | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.