Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Oct 1996 14:12:38 -0700
From:      John Polstra <jdp@polstra.com>
To:        bde@zeta.org.au
Cc:        current@FreeBSD.org, phk@FreeBSD.org, wollman@lcs.mit.edu
Subject:   Re: <sys/queue.h>
Message-ID:  <199610202112.OAA04687@austin.polstra.com>
In-Reply-To: <199610201947.FAA16430@godzilla.zeta.org.au>
References:  <199610201947.FAA16430@godzilla.zeta.org.au>

next in thread | previous in thread | raw e-mail | index | archive | help
> >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 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.  (I know,
this is C, not C++.  But the idea that the name of a type should
not carry unnecessary information about its representation is a
valid one.)

Personally, I favor PHK's idea.  It widens the applicability of
the list macros, without sacrificing any existing applicability.
(I am assuming that PHK's proposal includes an implicit offer to
suitably modify the existing code that the change breaks.)

Another consideration worth noting:  The single example of something
similar in the ANSI/ISO C standard, offsetof(), uses PHK's approach.
Again, this is precedent for using a type rather than a structure tag
as the macro argument.

John
--
   John Polstra                                       jdp@polstra.com
   John D. Polstra & Co., Inc.                Seattle, Washington USA
   "Self-knowledge is always bad news."                 -- John Barth



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610202112.OAA04687>