digitalmars.D.learn - no release-only version?
- Bill Baxter (9/9) Mar 06 2008 Am I right in thinking there's no built-in way to specify a block of
- bearophile (19/21) Mar 07 2008 Days ago I was looking for the same thing.
- Bill Baxter (3/30) Mar 07 2008 Ha. I was afraid of an answer like that. :-)
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
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
bearophile wrote:Bill Baxter Wrote:Ha. I was afraid of an answer like that. :-) --bbAm 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