I am working on some code that mixes OCaml and C, the functions caml_release_runtime_system() and caml_acquire_runtime_system() were introduced in OCaml 3.12 (they were called something else in earlier versions) but I would like to be compatible back to 3.10 if possible, is there an #ifdef I can use for that? I have had a look through the headers (in /usr/lib/ocaml/caml on my Debian system) and can’t find anything that looks like it might. Thanks!
UPDATE: this is what I did
This is what I did:
#if OCAML_VERSION_MINOR >= 12
#include <caml/threads.h>
#else
#include <caml/signals.h>
#endif
#ifndef caml_acquire_runtime_system
#define caml_acquire_runtime_system caml_leave_blocking_section
#define caml_release_runtime_system caml_enter_blocking_section
#endif
The
ocamloptandocamlcbinaries supports-vnumand-versionswitches for getting the version number:This switch is supported in 3.12.0 and the example text in the documentation suggests that 3.11.0 also supports it. I don’t have 3.10.0 handy but nlucaroni (whose OCaml Fu looks stronger than mine) indicates in the comments that 3.10.0 does have
ocamplopt -version.So you could add something like this to your Makefile:
And then pass those to your compiler using
-DOCAML_VERSION_MAJOR=$(OCAML_VERSION_MAJOR),-DOCAML_VERSION_MINOR=$(OCAML_VERSION_MINOR), …