Print Date and Time In Visual Studio C++ build?

后端 未结 5 1129
故里飘歌
故里飘歌 2020-12-17 23:49

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 B         


        
5条回答
  •  我在风中等你
    2020-12-18 00:10

    Use preprocessor's __DATE__ and __TIME__.

    printf("Binary build date: %s @ %s\n", __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
    

提交回复
热议问题