Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!cs.utexas.edu!swrinde!emory!hubcap!ncrcae!ncrlnk!ncrwic!encad!enprt!tsnider From: tsnider@enprt.Wichita.NCR.COM (Tim Snider) Newsgroups: comp.lang.c Subject: Re: #define DEBUG... (using printf for debugging) Message-ID: <647@enprt.Wichita.NCR.COM> Date: 7 May 90 12:55:44 GMT References: <11290@hoptoad.uucp> <40628@cornell.UUCP> <12780@smoke.BRL.MIL> Reply-To: tsnider@enprt.Wichita.NCR.COM (Tim Snider) Organization: NCR Corporation, Wichita KS Lines: 19 Keywords: I was reading the stuff about DEBUG and here's what we do: #define DEB(n,a) if ( ldebug > n ) prt a The debugs can be turned on and off interactively by setting n to the desired value. You don't have to take old debug statements out just turn up the value for n so they won't print. The prt function is just a shell for the appropriate printf or fprintf statements depending on where/how the code is being executed. A typical DEBUG statment looks like: DEB (0, (" glorp %x glob %x splat %x", glorp, glob, splat)); The only negative thing about this method is that braces must be used around ifs etc. ------------------------------------------------------------------------- Tim Snider NCR Peripherial Products Div. Wichita Ks. tsnider@wichita.NCR.COM