On Tue, Apr 12, 2022 at 10:07:15AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: > On 4/11/22 01:57, KytoDragon wrote: > > > Is there any way to import version specifiers from a separate file? > > Have you tried mixing in the versions? Have one file with the versions > in it: > > // file: 'versions' > version = x; > > Then mix it in: > > mixin (import ("versions")); > > version (x) { /* ... */ } > > Seems to work for me. [...]
If you need globally-defined versions, I'd just use the command-line option `-version=MyVersionA -version=MyVersionB ...`. Or, if you absolutely have to define versions in a source file, why not just use enums + static if instead: // versions.d module versions; enum MyVersionA = true; enum MyVersionB = true; // program.d import versions; static if (MyVersionA) { ... } else { ... } // ... and so on T -- An elephant: A mouse built to government specifications. -- Robert Heinlein