Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28991 Discussions

Compiler directive to get build date

OP1
New Contributor III
1,452 Views

Hi,

I would like to have my code display automatically, when launched, a string containing the date and time of the last build I did of the code (or of some of its subroutines). How can I do this? I use Visual Studio 2005 and IVF.

Thank you!

Olivier

0 Kudos
7 Replies
TimP
Honored Contributor III
1,452 Views
Quoting - opmkl

I would like to have my code display automatically, when launched, a string containing the date and time of the last build I did of the code

This could be done with /Qfpp and the __DATE__ macro, as described in the Using FPP directives section of ifort documentation.

0 Kudos
OP1
New Contributor III
1,452 Views
Quoting - tim18

This could be done with /Qfpp and the __DATE__ macro, as described in the Using FPP directives section of ifort documentation.

Thank you for the answer... I guess this only partially covers what I want to do though.

I am aware of the __DATE__ and __TIME__ variables accessible through the fpp preprocessor. This will give me the date and time at which the subroutine containing these definitions have been last compiled.

However, what I need is the time and date of the last successful build of my project... not just the last compile date/time of a particular subroutine. My original question was not clear enough.

For instance, if my main program declares/uses __DATE__ and __TIME__ and ifI mostly do work on one of the many subroutines it calls, I may very well end up with an inaccurate information... (an older build date than the actual date at which the program was linked).

Any other idea? Can we build on the use of __DATE__ etc... to get where I want to go, or should I try an alternate route?

Thanks,

Olivier

0 Kudos
TimP
Honored Contributor III
1,452 Views

The usual procedure, when you want the date of the last change to the build, is to put in a subroutine for this purpose, and force it to rebuild every time.

0 Kudos
OP1
New Contributor III
1,452 Views
Quoting - tim18

The usual procedure, when you want the date of the last change to the build, is to put in a subroutine for this purpose, and force it to rebuild every time.


Tim, yes, this seems fairly logical - and I am trying to do this. This may be a silly question... but how do I force a specific subroutine to be fpp'ed and then linked with the other subroutines from within Visual Studio? Do I need to create some type of "pre-build event" ?

In other words, how do I tell Visual Studio/IVF to always fpp and compile a specific subroutine prior to compiling and linking it with the other elements of my program (even when this subroutine has not been modified)? It seems that Visual Studio will only compile subroutines which source has been changed since the last build. How does it keep track of this? Can we get around this?

Olivier

0 Kudos
Steven_L_Intel1
Employee
1,452 Views

Yes, a pre-build event would be what you want. I did some experimentation and got this to work, but not the way I was expecting.

It seems that the preprocessor does not expand macros within quoted strings. I was trying something like:

print *, "__DATE__ __TIME__"

but what I would get is:

__DATE__ __TIME__

Upon closer reading of the docs, I see that these macros expand themselves to a quoted literal string. So this works:

print *, __DATE__, " ", __TIME__

Now the trick is to get this compiled every time. I could get this to happen with a post-build event that deleted the object from compiling the source with the __DATE__ macro, but then VS would complain if I tried to run the program because it was "out of date". So far, all of the combinations I have tried have failed in one way oe another. Perhaps someone else has an idea.

BTW. the switch to invoke the preprocessor is /fpp, not /Qfpp.

0 Kudos
OP1
New Contributor III
1,452 Views

Yes, a pre-build event would be what you want. I did some experimentation and got this to work, but not the way I was expecting.

It seems that the preprocessor does not expand macros within quoted strings. I was trying something like:

print *, "__DATE__ __TIME__"

but what I would get is:

__DATE__ __TIME__

Upon closer reading of the docs, I see that these macros expand themselves to a quoted literal string. So this works:

print *, __DATE__, " ", __TIME__

Now the trick is to get this compiled every time. I could get this to happen with a post-build event that deleted the object from compiling the source with the __DATE__ macro, but then VS would complain if I tried to run the program because it was "out of date". So far, all of the combinations I have tried have failed in one way oe another. Perhaps someone else has an idea.

BTW. the switch to invoke the preprocessor is /fpp, not /Qfpp.

Yes, this idea of deleting the object file after the build (so that it has to be compiled for the next buid) doesn't work so well... because you can't use the debugger in this case.

Anyone has a solutionfor this?

Olivier

0 Kudos
DavidWhite
Valued Contributor II
1,452 Views
Quoting - opmkl

Yes, this idea of deleting the object file after the build (so that it has to be compiled for the next buid) doesn't work so well... because you can't use the debugger in this case.

Anyone has a solutionfor this?

Olivier

One alternative method (not foolproof) is at runtime to read the timestamp on the .exe file.

David

0 Kudos
Reply