#define DEBUG... (using printf for debugging)

Verstoep C versto at cs.vu.nl
Tue May 8 21:47:49 AEST 1990


About one year ago a public domain package written by Fred Fish,
appropriately called DBUG, appeared on the net.
It's main feature is that it you can select, as a commandline option,
the debug statements you want. For example (just snapped from another window):

        DBUG_PRINT("cluster", ("re-evaluating parameter `%s'",
			       param->par_idp->id_text));
or
	DBUG_EXECUTE("objects", { PrintObject(obj); });

On the commandline you can then say (amake being the program I'm working on):

	amake -%d,cluster
or
	amake -%d,cluster,objects

which means that only the debug statements with the keywords mentioned will
be executed. As shown above, a debug statement can be a generic print statement
or an arbitrary piece of code by means of a DBUG_EXECUTE.
If the program is compiled with the -DDBUG_OFF flags, all debugging code
is automatically excluded, so you'll never have to remove a debug statement
for efficiency reasons.
Needless to say, this package is especially great for large programs under
development. Besides the features mentioned it also has a kind of profiler and
function tracer built-in, although I don't use those currently.

If you're interested in the package, you could try to get it from one of
the archives, or else contact me.

Kees Verstoep (versto at cs.vu.nl)



More information about the Comp.lang.c mailing list