Article View: news.software.nntp
Article #90817Re: Libraries using longjmp for error handling
From: Richard Kettlewell
Date: Sat, 30 Sep 2023 08:37
Date: Sat, 30 Sep 2023 08:37
32 lines
2361 bytes
2361 bytes
Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> writes: > Richard Kettlewell wrote: >> It’s more than 20 years since I last had to integrate a C library which >> reported errors via longjmp() and I’m still bitter about it. > > I have never encountered a library which does that. Which library was > that? libpng >> As a matter of API design, I’d rather C library communicated errors >> via return values (and pointer parameters, where more complex error >> information is required). > > Personally, i think that, at least for a library, an error should > _only_ be communicated by return value. If more complex information > is required, then the return value can be made more complex. I don't > think i've ever used a library that communicates information via a > pointer parameter. Return value plus a pointer to additional information can certainly be transformed into a struct containing both, though there’s an impact on source code verbosity, object code size and performance. For example if the extra information goes up to, say, 64 bytes, putting it in a return value commits you to a 64-byte copy on every return. However if it’s a pointer parameter, you only need to fill in the fields relevant to the error that actually happened. In the happy path, where there’s no error, that’s none of them. -- https://www.greenend.org.uk/rjk/
Technical Details
Message-ID:
<wwvil7sxdig.fsf@LkoBDZeT.terraraq.uk>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mailReferences:
<65SQM.565977$9o89.411905@fx05.ams4>Show Full Headers
Complete Article Headers
Message-ID: <wwvil7sxdig.fsf@LkoBDZeT.terraraq.uk>
Subject: Re: Libraries using longjmp for error handling
Date: Sat, 30 Sep 2023 09:37:43 +0100
From: Richard Kettlewell <invalid@invalid.invalid>
References: <65SQM.565977$9o89.411905@fx05.ams4>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mail
Newsgroups: news.software.nntp,comp.lang.c
Organization: terraraq NNTP server
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:+C7u7K71lS/9FNLh9qUvAXaiHb4=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO