From owner-freebsd-net Mon Oct 26 15:05:10 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id PAA04522 for freebsd-net-outgoing; Mon, 26 Oct 1998 15:05:10 -0800 (PST) (envelope-from owner-freebsd-net@FreeBSD.ORG) Received: from ns1.yes.no (ns1.yes.no [195.204.136.10]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA04511 for ; Mon, 26 Oct 1998 15:05:07 -0800 (PST) (envelope-from eivind@bitbox.follo.net) Received: from bitbox.follo.net (bitbox.follo.net [195.204.143.218]) by ns1.yes.no (8.9.1a/8.9.1) with ESMTP id AAA01917; Tue, 27 Oct 1998 00:04:29 +0100 (CET) Received: (from eivind@localhost) by bitbox.follo.net (8.8.8/8.8.6) id AAA27850; Tue, 27 Oct 1998 00:04:28 +0100 (MET) Message-ID: <19981027000427.59289@follo.net> Date: Tue, 27 Oct 1998 00:04:27 +0100 From: Eivind Eklund To: Garrett Wollman Cc: freebsd-net@FreeBSD.ORG Subject: Re: questions of taste.. mbuf header change References: <199810252219.RAA10102@whizzo.transsys.com> <199810261712.MAA19008@khavrinen.lcs.mit.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1i In-Reply-To: <199810261712.MAA19008@khavrinen.lcs.mit.edu>; from Garrett Wollman on Mon, Oct 26, 1998 at 12:12:55PM -0500 Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Mon, Oct 26, 1998 at 12:12:55PM -0500, Garrett Wollman wrote: > (You have stumbled into one of the most annoying misfeatures of the C > language: there is no way to actually USE an incomplete structure that > is even marginally useful; in order to have opaque objects it is > necessary to insert a level of indirection which is less than > desirable in a low-level context such as this.) Well, there is one nasty trick: Create a non-opaque definition of a variable as an anonymous structure, then fill in a char[] with the size of the structure, minus the size of the first element (which you need to get the correct alignement). Like this: struct something; static struct { struct something *something; ... more struct defintion here ... } anonymous_stuff; struct stuff { struct something *do_not_use_this_under_any_circumstance; char filler[sizeof(anonymous_stuff) - sizeof(anonymous_stuff.something)]; }; This is not allowed to fail in standard C. However, it may well produce a bunch of warnings, and I don't particularly like it. It will make any cross-file checker (like a good lint) SCREAM (at least until you set up the necessary filters for those warning messages). Eivind. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message