Obtaining a Compilation Datestamp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BrighterLater
    New Member
    • Dec 2006
    • 6

    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.
  • svsandeep
    New Member
    • Nov 2006
    • 15

    #2
    Originally posted by BrighterLater
    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

    Comment

    • BrighterLater
      New Member
      • Dec 2006
      • 6

      #3
      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?

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Originally posted by BrighterLater
        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

        Code:
        "Prog: Bodgit, Version: 0.0.0, Compiled: " __DATE__

        Comment

        • BrighterLater
          New Member
          • Dec 2006
          • 6

          #5
          Thank you for both replies. The second one gives me exactly the solution I hoped for - Mike

          Comment

          Working...