Solved

How can I log the date when a program was compiled in visual studio?

Posted on 2007-11-27
6
579 Views
Last Modified: 2013-12-14
Hi,

I am writing a VS 2005 native c++ console application. Each time I run it, I would like it to log to file the date on which it was compiled.  How can I do this?  

I know how to log stuff to files... the thing I can't figure out is how to obtain a date once at compile time such that it remains a runtime constant.

thanks
0
Comment
Question by:highqllc
6 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 250 total points
ID: 20359102
You could use the __DATE__ and __TIME__ macro's. As example :

        printf("%s %s\n", __DATE__, __TIME__);
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20359115
or more C++-y :

        std::cout << __DATE__ << " " << __TIME__ << std::endl;
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 150 total points
ID: 20359118
The predefined macro __DATE__ allowes to do that, e.g.

printf("Module compiled on %s", __DATE__);
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 14

Assisted Solution

by:wayside
wayside earned 100 total points
ID: 20359122
Use the __DATE__ macro. Add something like

char *compileDate = __DATE__;

in your code.
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 150 total points
ID: 20359124
0
 

Author Comment

by:highqllc
ID: 20359137
Awesome. Perfect.

How on earth do I divy out points here? :)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now