Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Oct 1996 20:11:45 +0900 (JST)
From:      Michael Hancock <michaelh@cet.co.jp>
To:        Poul-Henning Kamp <phk@critter.tfs.com>
Cc:        John Polstra <jdp@polstra.com>, bde@zeta.org.au, current@FreeBSD.org, wollman@lcs.mit.edu
Subject:   Re: <sys/queue.h> 
Message-ID:  <Pine.SV4.3.93.961021200032.24461B-100000@parkplace.cet.co.jp>
In-Reply-To: <25642.845877311@critter.tfs.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 21 Oct 1996, Poul-Henning Kamp wrote:

> >It's questionable to define a typedef just to save typing the word struct.
> 
> The reason I do it is not to save 7 chars of typing.
> 
> It's because we are talking about a self-contained type that carries
> with it all the operations you can perform on it.

I think you should do the changes you mention to queue.h and change the
man page example to the following...

*** foo1	Mon Oct 21 20:06:06 1996
--- foo2	Mon Oct 21 20:05:33 1996
***************
*** 1,10 ****
  #include <sys/queue.h>
  
! SLIST_HEAD(slisthead, entry) head;
  struct slisthead *headp;		     /* Singly-linked List head. */
  struct entry {
  	int i;
! 	SLIST_ENTRY(entry) entries;     /* Singly-linked List. */
       } *n1, *n2, *n3, *np;
  
  
--- 1,10 ----
  #include <sys/queue.h>
  
! SLIST_HEAD(slisthead, struct entry) head;
  struct slisthead *headp;		     /* Singly-linked List head. */
  struct entry {
  	int i;
! 	SLIST_ENTRY(struct entry) entries;     /* Singly-linked List. */
       } *n1, *n2, *n3, *np;
  
  
The original mixes up tag names and type names, which is a bogus thing to
do.

Use typedefs for scalars such as dev_t and for complex objects that
combine arrays, pointers, structs, and functions.

For simple structs, the typedef doesn't gain you much aside from not
having to type "struct".

Regards,


Mike Hancock





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SV4.3.93.961021200032.24461B-100000>