no release-only version?
Bill Baxter
dnewsgroup at billbaxter.com
Fri Mar 7 17:54:31 PST 2008
bearophile wrote:
> Bill Baxter Wrote:
>> Am I right in thinking there's no built-in way to specify a block of
>> code that gets disabled only in -release builds?
>
> Days ago I was looking for the same thing.
> At run time it's possible to know what you ask for (doesn't work in D 2.x, tan(0.9) is run in compile time, I presume):
>
> import std.stdio: writefln;
> import std.math: tan;
>
> void main() {
> bool release_mode = true;
> try {
> int[1] a;
> int el = a[ cast(int)tan(0.9) ];
> }
> catch (Error e) {
> release_mode = false;
> }
>
> writefln(release_mode);
> }
>
> But you can't use it in a static if.
>
> Bye,
> bearophile
Ha. I was afraid of an answer like that. :-)
--bb
More information about the Digitalmars-d-learn
mailing list