打印日期和时间在Visual Studio C ++构建? [英] Print Date and Time In Visual Studio C++ build?

查看:325
本文介绍了打印日期和时间在Visual Studio C ++构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何打印日期和时间以用于构建的目的。 Ie:当我的应用程序的控制台启动时,我想这样做:

How would I print the date and time for the purposes of the build. Ie: When the console for my application starts up I want to do this:


Binary Build date: 03/03/2009 @ 10:00AM


对于所有应用程序,对于程序员,特别是在团队环境中,这将是一个超级有用的函数。

I think this would be a super useful function for all applications to have behind the scenes for programmers, especially in a team environment.

有一个简单的方法使用Visual Studio 2008在C ++中。谢谢。

Is there a simple way to do this using Visual Studio 2008 in C++. Thanks.

推荐答案

使用预处理器 __ DATE __ __TIME __

printf("Binary build date: %s @ %s\n", __DATE__, __TIME__);

为了确保包含此代码的cpp文件是真正编译的,我使用touch-utility作为预建步骤:touch file.cpp

For making sure that cpp file that contains this code is really compiled, I use touch-utility for file as a pre-build step: touch file.cpp

Touch.bat:

Touch.bat:

@copy nul: /b +%1 tmp.$$$
@move tmp.$$$ %1

这篇关于打印日期和时间在Visual Studio C ++构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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