Print Date and Time In Visual Studio C++ build?(在 Visual Studio C++ 构建中打印日期和时间?)
问题描述
为了构建的目的,我将如何打印日期和时间.即:当我的应用程序的控制台启动时,我想这样做:
<块引用>二进制构建日期:03/03/2009 @ 10:00AM我认为这对于所有应用程序在后台对程序员来说都是一个超级有用的功能,尤其是在团队环境中.
有没有一种简单的方法可以在 C++ 中使用 Visual Studio 2008 来执行此操作.谢谢.
使用预处理器的__DATE__和__TIME__.
printf("二进制构建日期:%s @ %s
", __DATE__, __TIME__);为了确保真正编译包含此代码的 cpp 文件,我使用 touch-utility for file 作为预构建步骤:touch file.cpp
Touch.bat:
@copy nul:/b +%1 tmp.$$$@move tmp.$$$ %1How 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.
Is there a simple way to do this using Visual Studio 2008 in C++. Thanks.
Use preprocessor's __DATE__ and __TIME__.
printf("Binary build date: %s @ %s
", __DATE__, __TIME__);
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:
@copy nul: /b +%1 tmp.$$$
@move tmp.$$$ %1
这篇关于在 Visual Studio C++ 构建中打印日期和时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Visual Studio C++ 构建中打印日期和时间?
基础教程推荐
- CString 到 char* 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
