Optional compilation via PPX: define from command line

I know about to OCaml-friendly way to use optional compilation: camlp5 preprocessor and ppx_optcomp. The latter seems not to allow defining variable from command line switch which is mentioned in the README.

Pseudo-function defined(identifier) may be then used in expressions to check whether a given identifier has been defined. Note that identifiers that were not defined or undefined beforehand are assumed to be a typo, and therefore are rejected, with a notable exception of

[%%ifndef FOO]
[%%define FOO]

And camlp5 approach doesn’t play fiendly with OCamlformat during my experiments.

Question: do you know any other ppx-based rewriters for optional compilation? Do they allow defining names from command line?

1 Like