getting compile-time date and time without macros

前端 未结 3 1818
粉色の甜心
粉色の甜心 2021-01-05 18:30

using c++

I compile my code on an automated schedule and need to use the time at which the code was compiled in the code itself. Currently I\'m just using the

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-05 18:57

    It's not clear to me what you want. If it's the last modified time of the file, getting it will depend on your system and build system: something like -D $(shell ls -l --time-style=long-iso $< | awk '{ print $7, $8 }') could be used in the compiler invocation with GNU make under Linux, for example. But of course, it means that if an include file was changed, but not the source, the time and date wouldn't reflect it.

提交回复
热议问题