-
Notifications
You must be signed in to change notification settings - Fork 232
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
Define macros with CompCert's version number #284
Conversation
As suggested in #282, it can be useful to #ifdef code depending on specific versions of CompCert. Assuming a version number of the form MM.mm or MM.mm.pp the following macros are predefined: __COMPCERT_MAJOR__=MM (the major version number) __COMPCERT_MAJOR__=mm (the minor version number) __COMPCERT_PATCHLEVEL__=pp (the patchlevel, or 0 if none) __COMPCERT_VERSION__=MMmmpp (two decimal digits each, e.g. 30500 for version 3.5)
There is a slight collision with our version numbers which look like Therefore it would be nice to add an additional define, e.g. |
Thanks, the extension looks good. |
You're right about Concerning the Finally, I'm not sure the PATCHLEVEL part is useful. For the public version the only cases where we've used 3-level version numbers was to adapt to several versions of Coq, e.g. 3.0 was for Coq 8.5 and 3.0.1 was for Coq 8.6 but otherwise functionally identical, so there was no point in announcing this difference to the C code that is being compiled. Getting rid of the patchlevel part also makes the Opinions welcome! |
I think the presence of |
Major and minor numbers are enough, we don't need a patchlevel. As a consequence __COMPCERT_VERSION__ is 305, not 30500, for version 3.05.
OK, we're very much in agreement. I removed the PATCHLEVEL and simplified VERSION accordingly. The code also gets simpler. |
I have a feeling that we are all happy about this PR, so let me merge ASAP. |
As suggested in AbsInt#282, it can be useful to #ifdef code depending on specific versions of CompCert. Assuming a version number of the form MM.mm , the following macros are predefined: __COMPCERT_MAJOR__=MM (the major version number) __COMPCERT_MINOR__=mm (the minor version number) __COMPCERT_VERSION__=MMmm (two decimal digits for the minor, e.g. 305 for version 3.5) We also define __COMPCERT_BUILDNR__ if the build number is not empty in file ./VERSION. Closes: AbsInt#282
As suggested in #282, it can be useful to
#ifdef
code depending on specific versions of CompCert.Assuming a version number of the form
MM.mm
or, the following macros are predefined:MM.mm.pp
__COMPCERT_MAJOR__=MM
(the major version number)__COMPCERT_MINOR__=mm
(the minor version number)__COMPCERT_PATCHLEVEL__=pp
(the patchlevel, or 0 if none)__COMPCERT_VERSION__=MMmm
(two decimal digits each, e.g. 305 for version 3.5)Having 3 macros for MAJOR, MINOR and PATCHLEVEL is what GCC and Clang do. (Edit: but during the discussion we found PATCHLEVEL useless.)
Having the combined VERSION macro is convenient to write tests such as