Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C includes don't provide a revision number #5666

Closed
vicuna opened this issue Jun 28, 2012 · 4 comments

Comments

Projects
None yet
1 participant
@vicuna
Copy link

commented Jun 28, 2012

Original bug ID: 5666
Reporter: didc
Status: closed (set by @xavierleroy on 2015-12-11T18:07:11Z)
Resolution: fixed
Priority: normal
Severity: feature
Version: 4.00.0+beta2/+rc1
Fixed in version: 4.00.0+dev
Category: configure and build/install
Monitored by: @ygrek @hcarty

Bug description

Hi,

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!!

File attachments

@vicuna

This comment has been minimized.

Copy link
Author

commented Jul 9, 2012

Comment author: @damiendoligez

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

@vicuna

This comment has been minimized.

Copy link
Author

commented Jul 10, 2012

Comment author: @ygrek

Adding a C include file would still be useful..

@vicuna

This comment has been minimized.

Copy link
Author

commented Jul 10, 2012

Comment author: @oandrieu

« (one more field in the custom_operations struct) »

Actually this field was introduced in 3.12.1

@vicuna

This comment has been minimized.

Copy link
Author

commented Jul 10, 2012

Comment author: didc

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.