Just wondering how I can get the time the program was compiled into my code dynamically, I'm guessing it'll be through my makefile somehow but my Google-fu has failed today. Any help would be great!

(GCC + make *only*)

Recommended Answers

All 3 Replies

Just wondering how I can get the time the program was compiled into my code dynamically, I'm guessing it'll be through my makefile somehow but my Google-fu has failed today. Any help would be great!

(GCC + make *only*)

I dont know whether i understood your question correctly.
Still this is what I think,
1. Write a source file or makefile to generate a header file at the time of compilation
2. Include the current time as a macro to that header file
3. In your source code, include that header file and print the macro.

So obvious it was difficult to see! That's exactly what I need, thanks.

I see that the thread is solved. However, using __DATE__ and __TIME__ (which are stanadrd predefined macros) looks more straightforward...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.