Defining compile-time constants?

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 17 08:38:40 PDT 2015


On Thursday, 17 September 2015 at 15:32:25 UTC, Tim K. wrote:
> I am wondering if there is any way to define constants to pass 
> to the compiler like in C (especially useful in combination 
> with Makefiles, for obvious reasons), i.e.:

My preference is to make an app.config module that lists these 
things as variables (or enums) in ordinary D code. Then tell 
users to edit that file to customize their build. (wp_config.php 
does this and people are reasonably happy with it. You could even 
write a little creation app if you wanted to avoid plain editing 
the file. Like makeconfig PREFIX="/usr/local" and it writes out 
the config.d file.)



More information about the Digitalmars-d-learn mailing list