www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - no release-only version?

reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Am I right in thinking there's no built-in way to specify a block of 
code that gets disabled only in -release builds?

This is how array bounds checking behaves, right?  Always performed 
unless -release specified.

But it seems there's no built-in version/debug statement that lets 
library code have the same behavior.  The 'debug' condition is similar 
but it's only on in -debug builds, not in builds with specify neither 
-debug nor -release.

--bb
Mar 06 2008
parent reply bearophile <bearophileHUGS lycos.com> writes:
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
Mar 07 2008
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
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
Mar 07 2008