[Box Backup-dev] NDEBUG in Win32 release (was: COMMIT r279 - box/chris/win32/vc2005-compile-fixes/lib/backupclient)

Ben Summers boxbackup-dev@fluffy.co.uk
Sat, 24 Dec 2005 23:22:37 +0000


On 23 Dec 2005, at 11:30, Chris Wilson wrote:

> Hi Ben,
>
>> [snip]
>>>  +#ifndef WIN32
>>>  	TRACE2("Reallocating EncodingBuffer from %d to %d\n",  
>>> mBufferSize,  NewSize);
>>>  +#endif
>> [snip]
>>
>> Set NDEBUG as a preprocessor definition in your release build  
>> settings, and all the trace statements will not be compiled in.  
>> It'll also remove some code which really shouldn't be in a release  
>> build.
>
> I considered that, but I _really_ want exception logging with  
> source files and line numbers in these builds. Unless I hack about  
> with Box.h, the only way to get them seems to be compiling without - 
> NDEBUG.

Doesn't that imply that you should be running a debug build instead?

>
> What's the extra code, assertions and memory leak checks?  
> Assertions I'm quite happy to keep, and memory leak checks don't  
> bother me too much unless they have a huge performance impact or  
> are likely to crash Box in different ways.

The memory leak code is nasty and invasive, and won't necessarily  
give the right answers anyway. There's an argument for leaving  
assertions in, but the style I've tried to follow is that an ASSERT  
will catch the error just before it's defensively coded anyway, so it  
shouldn't cause a major problem.

Users should not be running code compiled without NDEBUG, and if it's  
desirable to keep in code which defining it removes, we should be  
looking at changing the mechanism.

Ben