[KinoSearch] DEBUG() and ASSERT()
Nathan Kurz
nate at verse.com
Sun Sep 30 13:39:17 PDT 2007
On 9/28/07, Marvin Humphrey <marvin at rectangular.com> wrote:
> No worries, mate. Can you show me how you normally like your
> DEBUG and ASSERT macros set up?
I'm sorry, but I'm not going to have time to clean up my current
Debug.h file to your standards before leaving on a trip tomorrow. But
I've attached it in its current state. I may have broken it by
starting to make changes to it, but at least it shows what I'm aiming
for.
The things I like are ASSERT() statements that are run if compiled
#ifdef DEBUG, as opposed to the system assert() which is #ifndef
NDEBUG. I subscribe to the "Code Complete" theory that one's DEBUG
version should be so loaded down as to barely run, but the real
version should be unencumbered by unnecessary checks. I find the
simple DEBUG defined/undefined dichotomy better for this than the 2x2
DEBUG/NDEBUG.
I also like DEBUG() statements that can be controlled at runtime to
print debugging information. I do this based on the DEBUG environment
variable, and allows control at both the file and function level. It's
possible that there would be a better fit for KinoSearch. Done right,
the DEBUG statements in the code serve dual purpose as comments and
debugging aids.
It's a little tricky to integrate this system with the XS loader and
builder. I've done it before by creating a Makefile that creates both
a normal and debug version and changes the XS bootstrap function to
use libfoo.so or libfoo_debug.so according to the DEBUG environment
variable. For now it may be simpler to just build one at a time,
switching by hand.
Nathan Kurz
nate at verse.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Debug.h
Type: application/octet-stream
Size: 4403 bytes
Desc: not available
Url : http://rectangular.com/pipermail/kinosearch/attachments/20070930/35b8eff1/attachment-0001.obj
-------------- next part --------------
_______________________________________________
KinoSearch mailing list
KinoSearch at rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch
More information about the kinosearch
mailing list