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
Solved

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

Posted on 2007-11-27
6
586 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

828 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