tag:blogger.com,1999:blog-5268847417417953349.post962958701966019286..comments2024-02-11T03:28:39.770-05:00Comments on inactivity log for davidz: Writing a C library, part 3davidzhttp://www.blogger.com/profile/18166813552495508964noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-5268847417417953349.post-45791699409270317402011-07-05T19:42:47.856-04:002011-07-05T19:42:47.856-04:00@Phillip Fry (Is there an article on [linux kernel...@Phillip Fry (Is there an article on [linux kernel way of errno] I can read?): Not that I know of, but http://jengelh.medozas.de/2011/0705-lkerrno.php for a start.j.enghttps://www.blogger.com/profile/09615346206411435754noreply@blogger.comtag:blogger.com,1999:blog-5268847417417953349.post-49073765462675770412011-07-04T10:05:15.228-04:002011-07-04T10:05:15.228-04:00@rotjberg: the point is that the code is easily gr...@rotjberg: the point is that the code is easily grep(1)'able - also mentally grep'able which is what I tried to convey in the snippet you posted. If you've ever worked on e.g. a large c++ or Java codebase you will know what I'm talking about.davidzhttps://www.blogger.com/profile/18166813552495508964noreply@blogger.comtag:blogger.com,1999:blog-5268847417417953349.post-20199028291874610302011-07-03T14:34:05.176-04:002011-07-03T14:34:05.176-04:00> One benefit of using namespaces in C (one tha...> One benefit of using namespaces in C (one that<br />> ironically is not present in a language with proper<br />> support for namespaces), is that it's a lot easier to<br />> pinpoint what the code is doing by just looking at a<br />> fragment of the source code<br />actually it is a feature of the language with namespace support. C programmers maybe never heard of it in their whole life, but for completeness its called "abstraction" ;)<br /><br />Its useful for instance when you port some code from gtk to clutter. Then all you have to do is change the type of my_container form GtkContainer to ClutterContainer instead of changing all the calls on my_container.<br />Of course this only works if you got the abstraction of your own code right in the first place.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5268847417417953349.post-55685791381543557572011-06-30T22:01:22.990-04:002011-06-30T22:01:22.990-04:00One lesson learned on the topic of namespaces for ...One lesson learned on the topic of namespaces for me was to *not* use abbreviations for library names. In my pet project buzztard I initially named a library libbtcore and that happened to later on clash with a libbtcore from ktorrent. I realized that 'bt' could mean lots of things from buzztard, bittorrent, bluetooth and decided to rename my lib to libbuzztard-core. The ktorrent guy did not rename theirs upon request though.Stefan Sauerhttps://www.blogger.com/profile/07581829597044799690noreply@blogger.comtag:blogger.com,1999:blog-5268847417417953349.post-75187017387901319922011-06-30T18:39:46.267-04:002011-06-30T18:39:46.267-04:00Very nice articles - thank you!
When it comes er...Very nice articles - thank you! <br /><br />When it comes error handling I have made it a principle that _all_ functions calling abort() should have an accompanying _validate_input() function which the timid user can call first.Joakim Hovehttps://www.blogger.com/profile/05855345395896096223noreply@blogger.comtag:blogger.com,1999:blog-5268847417417953349.post-73443732398905684442011-06-30T17:09:46.990-04:002011-06-30T17:09:46.990-04:00>The Linux kernel in contrast shows how to do w...>The Linux kernel in contrast shows how to do without such a global.<br /><br />Is there an article on this I can read? Please post if so. It sounds interesting.Philip Fryhttps://www.blogger.com/profile/15991090592338188218noreply@blogger.comtag:blogger.com,1999:blog-5268847417417953349.post-36443376906341384672011-06-30T11:21:05.952-04:002011-06-30T11:21:05.952-04:00>[errno] (since it's thread-safe and every ...>[errno] (since it's thread-safe and every C programmer knows it)<br /><br />It may be safe from other threads due to TLS, but it is still a object with global scope, which results in having to longwindingly save and restore errno across calls to other opaque library functions. The Linux kernel in contrast shows how to do without such a global.j.enghttps://www.blogger.com/profile/09615346206411435754noreply@blogger.comtag:blogger.com,1999:blog-5268847417417953349.post-64477092875214626092011-06-30T07:25:07.870-04:002011-06-30T07:25:07.870-04:00This is a really nice resource, thanks!This is a really nice resource, thanks!Robert Ancellhttps://www.blogger.com/profile/06377999550703204187noreply@blogger.com