Re: Hard-coding compile date/options



Richard Maine <nospam@xxxxxxxxxxxxx> wrote:

Lorents <lorents@xxxxxx> wrote:
In developmental versions of my programs I sometimes find it useful to
include in the executable the compile date and the compiler options
used. I'm trying to find the neatest way of doing this.
What I have done so far is to write a small shell script (BTW, I work on
Linux) which creates a small file containing a fortran module which is
then USE'd by my program.
...
Which is what I want. However, I wonder if there is a way to avoid this
roundabout procedure.

You won't find a more portable way than that. Yes, there are options
using preprocessors, but then you have to worry about compatibility with
the various pre-processors out there.

Hmm. One possible issue does occur to me, though. Compilation of the
multiple object files in a single program can potentially occur at
multiple dates/times. The larger the program gets, the more likely this
is to be a significant issue.

I'll leave to you the question of how important it might be for you to
track the compilation data of individual object files; that's a bit
broader question. I'll just note that if you do try to track such
multiple compilation times, you could run into trouble if you have
multiple program units compiled using different versions of the same
module. Something like an include file might work out better for that.

I also note that your module declares compilation_date and
compilation_details to be variables instead of parameters. For something
that is inherently intended to be defined at compile time, I would think
a parameter would be a more appropriate choice.

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
.



Relevant Pages

  • Re: namespaces and main()
    ... having multiple definitions is ... Actually it's quite a big problem for the linker to sort out - some ... translation unit and not compile it in any of the others. ... One way around the bloat issue is just to have a single compilation ...
    (comp.lang.cpp)
  • Re: VC++ Compiler multithreading
    ... up the compiling and linking process of VC++ compiler? ... You can be sure that all versions of VC++ utilize multiple threads in one ... This should make the compilation faster. ... multiple cores yet. ...
    (microsoft.public.vc.ide_general)
  • Re: Preprocessing with gcc -E
    ... compile source files in any order. ... to evaluate however consists of multiple compilation units. ... I would expect to get some error of type "multiple definition of" ...
    (comp.programming)
  • "sched: add vslice" causes horrible interactivity under load
    ... with 2.6.23.x I could have multiple "make -j3" compilation runs going ... in the background with no real problems, ... I did a git bisect starting from 9b73e76f3cf63379dcf45fcd4f112f5812418d0a ...
    (Linux-Kernel)
  • Re: 2 .cpp files
    ... Cald wrote: ... Many translators allow compilation of many source files into ... The object files were then linked together ... C++ Faq: http://www.parashift.com/c++-faq-lite C Faq: http://www.eskimo.com/~scs/c-faq/top.html alt.comp.lang.learn.c-c++ faq: ...
    (alt.comp.lang.learn.c-cpp)