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

Don't redefine macros with OCaml 4.12 #30

Merged
merged 1 commit into from
Feb 24, 2021

Conversation

MisterDA
Copy link
Contributor

Macros Val_none and Some_val are part of the standard library
starting with OCaml 4.12.

In some environments, redefining a macro triggers a compiler warning.
When warnings are treated as errors, the build fails.

Issue discussing the introduction of the macros, the problem, and the
fix: ocaml/ocaml#5154

Commit introducing the macros in the standard library:
ocaml/ocaml@973eeb1

Macros `Val_none` and `Some_val` are part of the standard library
starting with OCaml 4.12.

In some environments, redefining a macro triggers a compiler warning.
When warnings are treated as errors, the build fails.

Issue discussing the introduction of the macros, the problem, and the
fix: ocaml/ocaml#5154

Commit introducing the macros in the standard library:
ocaml/ocaml@973eeb1
MisterDA added a commit to MisterDA/ocaml that referenced this pull request Jul 2, 2020
If an OCaml C library already defines some of the new `Val_none`,
`Some_val`, `Is_none`, `Is_some`, `caml_alloc_some`, or `Tag_some`
macros; then the C compiler will likely warn for macro redefinition,
even if the macro definition are identical. In some setups that always
turn warnings to errors, this will block the compilation of the
library.

This problem happens in [ocaml-mccs][1].

The proposed [fix][2] for libraries is to only define the macros when
compiling with OCaml strictly older than 4.12, i.e.:

    #if OCAML_VERSION < 41200
    #define ...
    #endif

[1]: ocaml-opam/ocaml-mccs#30
[2]: ocaml#5154 (comment)
MisterDA added a commit to MisterDA/ocaml that referenced this pull request Jul 17, 2020
If an OCaml C library already defines some of the new `Val_none`,
`Some_val`, `Is_none`, `Is_some`, `caml_alloc_some`, or `Tag_some`
macros; then the C compiler will likely warn for macro redefinition,
even if the macro definition are identical.

This problem happens in [ocaml-mccs][1].

The proposed [fix][2] for libraries is to only define the macros when
compiling with OCaml strictly older than 4.12, i.e.:

    #if OCAML_VERSION < 41200
    #define ...
    #endif

[1]: ocaml-opam/ocaml-mccs#30
[2]: ocaml#5154 (comment)
@AltGr
Copy link
Collaborator

AltGr commented Feb 24, 2021

Thanks!

@AltGr AltGr merged commit 1d56d2f into ocaml-opam:master Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#define Val_some
2 participants