Expose OCaml version in C headers #6406
Original bug ID: 6406
I was specifically bitten by this commit: 05100e5#diff-f940572c32e55a7e40e7f693deea4c7bR42
Which changed, as far as I understand, a documented public API in an incompatible way between minor versions. This is horrible on its own, but the fact that there is no way to detect OCaml version in the C code to disambiguate makes it also impossible to work around.
Comment author: @gasche
Which "valid value" is used is not specified in the documentation, so I don't think it was correct to rely on a precise choice of initialization value in the first place.
Could you explain the ctypes use-case? I had a glimpse of the discussion but that was quite cryptic to someone not familiar with the implementation.
Comment author: @whitequark
A string is nearly impossible to perform comparisons on; how about OCAML_MAJOR OCAML_MINOR OCAML_PATCH, and in addition OCAML_VERSION that has the previous concatenated. That's how I usually seen it done.
E.g. for 3.12:
OCAML_MAJOR = 3
OCAML_MAJOR = 4
This way you have both conveniently separated version parts and a way to compare them... e.g. #if OCAML_VERSION >= 40200L