在Visual C ++可执行文件中输出编译时间戳? [英] Output compile time stamp in Visual C++ executable?

查看:101
本文介绍了在Visual C ++可执行文件中输出编译时间戳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将编译时间戳信息插入使用Visual C ++ 2005构建的可执行文件?我想在执行程序时能够输出这样的东西:

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 program:


这个build XXXX是在dd-mm-yy编译的, hh:mm。

This build XXXX was compiled at dd-mm-yy, hh:mm.

其中日期和时间反映项目构建的时间。

where date and time reflect the time when the project was built. They should not change with each successive call of the program, unless it's recompiled.

推荐答案

虽然不是您的确切格式, DATE 的格式为Mmm dd yyyy,而 TIME 的格式为hh:mm:ss。你可以创建一个这样的字符串并在任何打印例程中使用它:

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__ ".";

(另一个答案 TIMESTAMP 的注意事项只会显示修改日期/源文件的时间,而不是构建日期/时间。)

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

这篇关于在Visual C ++可执行文件中输出编译时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆