Hello,

2013/4/9 Étienne André <Etienne.Andre@univ-paris13.fr>
I've been using OCaml for a couple of years, but without using any advanced feature; so my question may be a little naive.
Is there any way to insert easily the current date and time of compiling, as well as, e.g., an incremental build number in an OCaml program? 
So that it is printed at runtime, e.g., in the program header.

This kind of information is part of your build process and are not directly accessible in OCaml. If you want to access it in your OCaml program, you have to pass them from the build environment to the program environment. As Jeremie Dimino said, the usual way is to general a small OCaml file at build time and to link it to your program.

For instance, if you use 'make', you could have the following lines in your Makefile:

VERSION=...
config.ml: Makefile
  echo "let version = \"$(VERSION)\"" > $@
  echo "let compilation_date = \"`date`\" >> $@
 
CMO_FILES = config.cmo ... (* other cmo files)

Of course, it is better to add the corresponding config.mli by hand:
config.mli:
val version: string
val date: string

Hope this helps,
Julien