Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!ames!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: Reporting errors from local libraries Message-ID: <10407@smoke.BRL.MIL> Date: 16 Jun 89 21:06:43 GMT References: <9449@alice.UUCP> <186@cbnewsd.ATT.COM> <25447@agate.BERKELEY.EDU> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 21 In article <25447@agate.BERKELEY.EDU> bks@ALFA.berkeley.edu ( Brad Sherman ) writes: >Where is the actual space for "errno" allocated? The usual implementation is for the C library to contain a module that defines storage for it, for example what you get when you compile: /* errno.c -- C library source for the "errno" data module */ int errno; (Actually, the module usually also contains an secret run-time support function that is used to log an error into errno and return a -1 value from the failed system call.) >If one has N libraries and all functions in these libraries return >0 on success and -1 on failure, and one wishes, say, to set an (extern) >integer "Localerrno" to provide additional info on failure, what is the >guruish way to proceed? The "errno" approach is a mistake, and I strongly recommend not returning values via external global variables. Use a better function interface, for example return 0 on success and non-zero error code on failure.