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