Output compile time stamp in Visual C++ executable?

前端 未结 6 911
借酒劲吻你
借酒劲吻你 2021-01-04 02:08

How can I insert compilation timestamp information into an executable I build with Visual C++ 2005? I want to be able to output something like this when I execute the progra

6条回答
  •  花落未央
    2021-01-04 02:52

    Though not your exact format, DATE will be of the format Mmm dd yyyy, while TIME will be of the format hh:mm:ss. You can create a string like this and use it in whatever print routine makes sense for you:

    const char *buildString = "This build XXXX was compiled at " __DATE__ ", " __TIME__ ".";
    

    (Note on another answer: TIMESTAMP only spits out the modification date/time of the source file, not the build date/time.)

提交回复
热议问题