cppo
cppo copied to clipboard
How to define a macro with value via command line?
I must be missing something but cppo -D VAL=1 test.ml doesn't work:
let x = VAL
is expanded into
#1 "test.ml"
let x =
#1
=1
The command line for that is cppo -D 'VAL 1'. If I remember correctly, it was simpler to implement that way so I didn't bother supporting the usual cpp syntax. In hindsight it was a bad decision.
I see. But maybe to support both -D 'VAL 1' and -D VAL=1? It shouldn't be that hard.
And it would be great if the syntax was mentioned in the docs.
I added an example to the command-line help.
I'm hesitant to support the = syntax. Reasons are:
- supporting two syntaxes for the same thing isn't great
- it's inconsistent with the syntax used inside files, where no equal sign is used
- it introduce an incompatibility, e.g.
-D 'EQ ='has now a new meaning
None of this is a big deal. Maybe we can support both syntaxes but deprecate the space-based syntax.