From owner-freebsd-current Sun Oct 20 15:11:33 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id PAA20069 for current-outgoing; Sun, 20 Oct 1996 15:11:33 -0700 (PDT) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id PAA20051; Sun, 20 Oct 1996 15:11:25 -0700 (PDT) Received: (from bde@localhost) by godzilla.zeta.org.au (8.7.6/8.6.9) id IAA19365; Mon, 21 Oct 1996 08:06:29 +1000 Date: Mon, 21 Oct 1996 08:06:29 +1000 From: Bruce Evans Message-Id: <199610202206.IAA19365@godzilla.zeta.org.au> To: bde@zeta.org.au, jdp@polstra.com Subject: Re: Cc: current@FreeBSD.org, phk@FreeBSD.org, wollman@lcs.mit.edu Sender: owner-current@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk >> 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 . And it An exception that proves the rule. A real c (sic) programmer would never use upper case in a type or variable name :-). is POSIX. I don't know the BSD history of DIR. >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.) At least in the kernel, you need to be intimately aware of the representation to write space- and time-efficient code. E.g., `auto foo_t foov;' is no good if foo_t might be a large struct, since the kernel stack is small. >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. I didn't completely understood phk's proposal. You can always use `struct foo' for the type in offsetof() provided the struct has a tag. The queue macros take a "type" arg which is actually a struct tag and prefix `struct ' to it. I agree that this is wrong. My objection is to using a typedef for `struct foo'. Bruce