[Aldor-l] Debug statements

Pippijn van Steenhoven pip88nl at gmail.com
Wed Dec 12 15:55:21 EST 2007


Hi Aldor Developers,

currently, I am trying to discover the origin of several bugs and I
found that constructs like (simplified in this mail)

#ifndef NDEBUG
#define DEBUG_IF(v,s)   if (v) { s; }
#else
#define DEBUG_IF(v,s)   Nothing
#endif

are used a lot. The problem with these is that they expand to a single
line after preprocessing, making it almost impossible to make sense of
debugger output (at least gdb is line based, not statement based). I
therefore suggest changing those into

#ifndef NDEBUG
#define DEBUG_IF(s)      if (s)
#else
#define DEBUG_IF(s)      if (0)
#endif

used as:

DEBUG_IF (condition) {
   print some debug information
}

instead of

DEBUG_IF (condition, {
   print some debug information
});

Besides the fact that debugging becomes much harder using the latter,
it is also ugly. The former is much more natural and looks like a
normal if (because in fact it is).

Pippijn




More information about the Aldor-l mailing list