是否可以存储并显示项目编译的日期?
我想在程序启动时打印此日期,以便了解使用的是哪个版本。目前我都是手工做的,比较麻烦。
我正在使用 Visual Studio 2010。
C++ 指定有一个特殊的预处理器宏,称为__DATE__
这是编译发生时间的字符串文字。还有一个对应的__TIME__
macro.
您可以这样使用:
const std::string compilation_date = __DATE__;
const std::string compilation_time = __TIME__;
...
std::cout << "This source file was compiled on date " << compilation_date
<< " and at the time " << compilation_time << '\n';
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)