Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Oct 1996 08:20:06 +0900 (JST)
From:      Michael Hancock <michaelh@cet.co.jp>
To:        "Hr.Ladavac" <lada@ws2301.gud.siemens.co.at>
Cc:        current@FreeBSD.org
Subject:   Re: <sys/queue.h>
Message-ID:  <Pine.SV4.3.93.961022080654.28970C-100000@parkplace.cet.co.jp>
In-Reply-To: <199610211147.AA020798458@ws2301.gud.siemens.co.at>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 21 Oct 1996, Hr.Ladavac wrote:

> E-mail message from Michael Hancock contained:
> >   
> > 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".
> 
> I have some strong feelings about that: namely, a typedef should be used
> for *any* type that is supposed to be opaque.
> 
> If my program does not need to know whether something is a struct or a 
> scalar or whatever, it *must not* know it either.  This tends to make
> interface maintenance trivial (i.e. you have to recompile the interface
> consumers, but you don't need to patch their sources as well).

It's rare that a struct changes to anything but another struct.  The only
thing that isn't opaque about 'struct foo_tag' is the word struct.  And
the hint is more useful to most people who use C for writing kernels and
similar systems than not.

Please don't go typedef happy and put it everywhere you find an
opportunity.  It has important uses, but not in every case.

I have a hard enough time as it is tracking names in the kernel.

Regards,


Mike Hancock




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