Path: utzoo!attcan!uunet!munnari.oz.au!mel.dit.csiro.au!yarra!pta!teti!teslab!andrew From: andrew@teslab.lab.OZ (Andrew Phillips) Newsgroups: comp.sys.amiga.programmer Subject: Re: Good Programming stops guru |||| and BNF of C++ Message-ID: <1190@teslab.lab.OZ> Date: 24 Jan 91 06:51:31 GMT References: <1806@winnie.fit.edu> <658@tnc.UUCP> <1991Jan11.073543.16293@zorch.SF-Bay.ORG> Reply-To: andrew@teslab.lab.oz.au (Andrew Phillips) Organization: Technology Evaluation Section, L.A.B., Sydney Lines: 36 In article <1991Jan11.073543.16293@zorch.SF-Bay.ORG> mykes@zorch.SF-Bay.ORG (Mike Schwartz) writes: >Manx supplies a routine called _abort() in the library which can be >used to make programs that EASILY clean up after themselves. ... For portability you would be better off using the ANSI routine onexit(), which allows you to register routines to be called when exit() is called. This has the advantage of allowing reusable routines to have this facility without _abort() having to know how they work internally. >panic(s, a1,a2,a3,a4,a5,a6,a7,a8) >ULONG s,a1,a2,a3,a4,a5,a6,a7,a8; /* who cares what type they were... */ >{ > printf(s, a1,a2,a3,a4,a5,a6,a7,a8); >... >The code for panic shows how (using 32-bit INT model of Manx) you can >make a printf() like routine without a lot of ugly looking code. The >drawback is that you are pushing a lot of parameters in a lot of places. Why not use vprintf() which is neater and is also ANSI, from memory. The above also won't work if you have too many parameters to panic. >panic0(v, s, a1,a2,a3,a4,a5,a6,a7,a8) --------^------- >ULONG s,a1,a2,a3,a4,a5,a6,a7,a8; /* ULONG can be int,short,byte, etc. */ >{ >... > panic0(IntuitionBase, "Can't open intuition\n"); This is a really good idea but, shouldn't "v" be declared to be a "void *" rather than defaulting to int. -- Andrew Phillips (andrew@teslab.lab.oz.au) Phone +61 (Aust) 2 (Sydney) 289 8712