Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!sunic!tut!hydra!kreeta!grano From: grano@cs.Helsinki.FI (Kari Gran|) Newsgroups: comp.lang.c Subject: Re: exception handling in C Message-ID: <4400@hydra.Helsinki.FI> Date: 9 Mar 90 00:17:02 GMT References: <4767@crltrx.crl.dec.com> <7990004@hpopd.HP.COM> Sender: news@cs.Helsinki.FI Organization: University of Helsinki, Department of Computer Science Lines: 24 There is a paper titled 'Excaption Handling in C' by Eric. S. Roberts, published by Digital Equipment Corp., 1989, which describes a simple exception handling mechanism implemented with preprocessor. The resulting code looks something like this: exception OpenError; TRY fp = myopen("test.dat", "r"); EXCEPT(OpenError) printf("Cannot open test.dat\n"); EXCEPT(....) ... ENDTRY and in your routines you can use RAISE to raise exceptions. The exceptions follow a dynamic call chain at runtime. Full source code is included in the paper; works well, according to my (minor) tests. Kari. -- Kari Grano grano@cs.helsinki.fi Hey, my opinions are just mine.. "I've got a thousand telephones that don't ring" - R.Z.