Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcsun!hp4nl!star.cs.vu.nl!versto From: versto@cs.vu.nl (Verstoep C) Newsgroups: comp.lang.c Subject: Re: #define DEBUG... (using printf for debugging) Message-ID: <6482@star.cs.vu.nl> Date: 8 May 90 11:47:49 GMT References: <103kla@physc1.byu.edu> Sender: news@cs.vu.nl Lines: 31 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@cs.vu.nl)