Date: Sun, 20 Oct 1996 23:29:51 +0200 From: Poul-Henning Kamp <phk@critter.tfs.com> To: John Polstra <jdp@polstra.com> Cc: bde@zeta.org.au, current@FreeBSD.org, wollman@lcs.mit.edu Subject: Re: <sys/queue.h> Message-ID: <24989.845846991@critter.tfs.com> In-Reply-To: Your message of "Sun, 20 Oct 1996 14:12:38 PDT." <199610202112.OAA04687@austin.polstra.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <199610202112.OAA04687@austin.polstra.com>, John Polstra writes: >> >Don't do that, then. It's horrid style anyway (IMAO), and you >> >/certainly/ don't see any native Berkeley code doing that. The style >> >guide should discourage the practice if it doesn't already. I disagree. >> >> I agree. Typedef should only be used for scalar types and function >> types. > >Why do you say that? There's already precedent for using typedefs >for structs in, for example, the "DIR" type of <dirent.h>. And it >is in line with C++ practice, where the struct, class, or union >keyword is almost never used outside of the declaration. This is actually why I do it. The code I'm crunching right now is pretty much C++ written in C, ie. object oriented. Not because I want to rewrite the kernel in C++ at a later date, but because it is the design model that fits this particular piece. My approach to fixing <sys/queue.h> would probably be to add the new macros for each kind of queue, rather than have to change all the code that uses it now: #define SLIST_HEAD_TYPE(name, type) \ struct name { \ type *slh_first; /* first element */ \ } (_TYPE suffix is open for discussion) I would probably add the _EMPTY, _NEXT, _PREV, _FIRST and _LAST macros to all the queues as apropriate while I'm there. I consider it a major flaw in <sys/queue.h> that you have to know anyting about the internal representation. -- Poul-Henning Kamp | phk@FreeBSD.ORG FreeBSD Core-team. http://www.freebsd.org/~phk | phk@login.dknet.dk Private mailbox. whois: [PHK] | phk@ref.tfs.com TRW Financial Systems, Inc. Future will arrive by its own means, progress not so.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?24989.845846991>