Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get current time at compile time?

I'm thinking about using current timestamp as a piece of version. I would like to retrieve that information at compile time. So ideally I would like to do:

constexpr long long currentTimestamp = getCurrentTimestamp();

Is that possible with C++14?

like image 468
freakish Avatar asked Nov 27 '22 10:11

freakish


1 Answers

Use standard C __TIME__ macro with __DATE__ macro. See this question for an example.

like image 101
Rinat Veliakhmedov Avatar answered Dec 10 '22 07:12

Rinat Veliakhmedov