in/out with -release

Jonathan M Davis jmdavisProg at gmx.com
Sat Mar 5 14:02:29 PST 2011


On Saturday 05 March 2011 13:54:08 Jonathan M Davis wrote:
> On Saturday 05 March 2011 05:30:23 Andrej Mitrovic wrote:
> > On 3/5/11, bearophile <bearophileHUGS at lycos.com> wrote:
> > > Jonathan M Davis:
> > >> Asserts are for
> > >> debugging, testing, and verifying code when developing, not for code
> > >> which is
> > >> released.
> > > 
> > > If you take a look at the dmd compiler, it's released with asserts in,
> > > and they give all those nice error messages I put in Bugzilla :-)
> > > 
> > > Bye,
> > > bearophile
> > 
> > Hmm. Are those shown when compiling a file with -debug? Or do I need
> > to compile DMD itself in debug/nonrelease mode to activate those error
> > messages?
> 
> You would need to compile dmd in debug mode if you wanted it to have
> assertions enabled, the same as any other C or C++ program in existence.
> That's the way that C/C++'s assert library works.

Actually, I take that back. The way that C/C++'s assert library works is that 
assertions are compiled in if NDEBUG is _not_ defined. What the "debug" build of 
a project does is entirely up to the project. The concept of debug and release 
versions isn't really built in to the language per se. Normally, debug versions 
compile in the debug symbols and release versions do not, and release versions 
typically are set up such that they don't run unnecessary stuff which would harm 
efficiency (such as assertions). But _exactly_ how debug and release versions are 
set up depends on the project.

In the case of dmd, it may be that some assertions are left in on the theory 
that this it's _really_ critical code and you _still_ want it to fail 
immediately when an assertion would have failed (whereas more typically, you'd 
compile out the assertions in release mode, assuming that you'd done enough 
testing in debug mode to find and fix all the bugs that they relate to). But to 
know exactly what dmd does with assertions, you'd have to look at its makefiles 
and possibly the code itself.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list