Global version/debug statements in file?
cc
cc at nevernet.com
Wed Feb 12 08:44:24 UTC 2020
Is there some way to globally declare version= or debug=
statements in a file and have them apply to the entire project
being compiled? As the documentation says these only apply to
the module scope they exist in, and need to be added to the
command line otherwise. It would be a bit easier for me to
maintain a separate .d source file when I want to add/comment out
statements for testing than to keep updating the build command
line. I tried using a mixin, such as:
// constants.d
module constants;
enum VERSIONS = q{
version=Compress;
};
// main.d
import constants;
mixin(VERSIONS);
void main() {
version(Compress)
writeln("Compress it!");
version(Decompress)
writeln("Decompress it!");
}
This does seem to work inside function bodies, but not at module
scope in the importing file. e.g.:
// main.d
import constants;
mixin(VERSIONS)
version(Compress) {
...
}
Gives: Error: version `Compress` defined after use
More information about the Digitalmars-d-learn
mailing list