generic define pragma + string alias (#20979)

* generic `define` pragma + string alias

* clean

* add tests and document

* remove char/float, minimize changelog
This commit is contained in:
metagn 2022-12-13 23:20:55 +03:00 • committed by GitHub
commit 9a50033d5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 218 additions and 53 deletions

View file

@ -8049,6 +8049,24 @@ used. To see if a value was provided, `defined(FooBar)` can be used.
The syntax `-d:flag`:option: is actually just a shortcut for
`-d:flag=true`:option:.
These pragmas also accept an optional string argument for qualified
define names.
```nim
const FooBar {.intdefine: "package.FooBar".}: int = 5
echo FooBar
```
```cmd
nim c -d:package.FooBar=42 foobar.nim
```
This helps disambiguate define names in different packages.
See also the [generic `define` pragma](manual_experimental.html#generic-define-pragma)
for a version of these pragmas that detects the type of the define based on
the constant value.
User-defined pragmas
====================