Solved

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

Posted on 2007-11-27
6
596 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

632 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