Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005666OCamlIncomingpublic2012-06-28 21:552012-07-10 19:40
Reporterdidc 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.00.0+beta2/+rc1 
Target VersionFixed in Version4.00.0+dev 
Summary0005666: C includes don't provide a revision number
DescriptionHi,

I am planning to include support for both 3.x and 4.x versions of the C API in the C stub parts of my libraries. However, I couldn't find a define in the C headers to verify which version of the runtime I'm compiling against. There's at least one change in the C API (one more field in the custom_operations struct), which can be easily tested without this feature, but I wonder if a more general way of checking the API version wouldn't be desirable.

Thank you!!
TagsNo tags attached.
Attached Files? file icon make-version-header.sh [^] (2,178 bytes) 2012-07-09 17:35

- Relationships

-  Notes
(0007671)
doligez (administrator)
2012-07-09 17:34

Instead of providing a C include file, which would only work for future versions of OCaml, I wrote a shell script that produces such an include file from the version number provided by ocamlc. I suggest that you include a copy of that script with your sources and use it in your Makefile.

I have uploaded it here, and added it to the tools/ directory.

Sample output:

for 4.00.0+beta2:
  #define OCAML_VERSION_MAJOR 4
  #define OCAML_VERSION_MINOR 00
  #define OCAML_VERSION_PATCHLEVEL 0
  #define OCAML_VERSION_ADDITIONAL "beta2"

for 3.12.1:
  #define OCAML_VERSION_MAJOR 3
  #define OCAML_VERSION_MINOR 12
  #define OCAML_VERSION_PATCHLEVEL 1
  #undef OCAML_VERSION_SUFFIX

for 3.07:
  #define OCAML_VERSION_MAJOR 3
  #define OCAML_VERSION_MINOR 07
  #define OCAML_VERSION_PATCHLEVEL 0
  #undef OCAML_VERSION_ADDITIONAL
(0007675)
ygrek (reporter)
2012-07-10 10:35

Adding a C include file would still be useful..
(0007676)
oandrieu (reporter)
2012-07-10 10:40

« (one more field in the custom_operations struct) »

Actually this field was introduced in 3.12.1
(0007697)
didc (reporter)
2012-07-10 19:40

My bad, I had ver. 3.11 and tried ver. 4 and assumed it was new. If it's the only thing that changed since then, it's probably not so much of a hurdle.
Generating the include file could be enough. This can be handled with regular Makefiles, OCamlMakefile (I tested this), and probably OMake too. For ocamlbuild, a solution maybe is writing the include script generator in ocaml and have it included somehow in myocamlbuild.ml.
Indeed, there's isn't a simple way to test from within the C stubs if a file effectively exists, so one would have to resort to using a test in the build scripts to check if the version include file exists or not, thus the solution offered seems better.
Thank you!

- Issue History
Date Modified Username Field Change
2012-06-28 21:55 didc New Issue
2012-07-09 17:25 doligez File Added: make-version-header.sh
2012-07-09 17:34 doligez Note Added: 0007671
2012-07-09 17:34 doligez Status new => resolved
2012-07-09 17:34 doligez Resolution open => fixed
2012-07-09 17:34 doligez Fixed in Version => 4.00.0+dev
2012-07-09 17:35 doligez File Deleted: make-version-header.sh
2012-07-09 17:35 doligez File Added: make-version-header.sh
2012-07-10 10:35 ygrek Note Added: 0007675
2012-07-10 10:40 oandrieu Note Added: 0007676
2012-07-10 19:40 didc Note Added: 0007697


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker