If you like ocambuild, an alternative is to add a small rule in your ocamlbuild plugin. The ocamlbuild wiki gives an example of ocamlbuild plugin that create a " version.ml" file in the _build directory at each build. You can then link your code with this version.ml file. http://brion.inria.fr/gallium/index.php/Automatic_Version_Generation Daniel 2013/4/11 Alain Frisch > On 04/09/2013 01:38 PM, Étienne André wrote: > >> I quite stupidly used the Unix.gettimeofday() function before realizing >> that it is of course executed at runtime. >> > > As others suggested, you can tell your build system to generate an ad hoc > file containing the compile-time information. Another approach is to use a > preprocessor to inject such compile-time information into the source code > "on the fly" during its compilation. This can be done with a dedicated > Camlp4 syntax extension or a -ppx preprocessor (available in trunk only, > with syntactic extension points being designed in the extension_points > branch of the OCaml SVN). > > As an illustration of the -ppx approach, I've created a tiny preprocessor > which uses the OCaml toplevel to evaluate expressions and inserts the > result as constants in the compiled code. > > The source code for this -ppx preprocessor can be found here: > > http://caml.inria.fr/cgi-bin/**viewvc.cgi/ocaml/branches/** > extension_points/experimental/**frisch/eval.ml?&view=markup > > and here is an example of what you can write with it: > > http://caml.inria.fr/cgi-bin/**viewvc.cgi/ocaml/branches/** > extension_points/experimental/**frisch/test_eval.ml?&view=**markup > > (To play with it, you need to checkout the extension_points branch and > after compiling it: cd experimental/frisch && make eval) > > -- Alain > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/**arc/caml-list > Beginner's list: http://groups.yahoo.com/group/**ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-**bugs >