From owner-freebsd-hackers Tue Aug 13 16:24: 8 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 86EF837B400 for ; Tue, 13 Aug 2002 16:24:06 -0700 (PDT) Received: from scaup.mail.pas.earthlink.net (scaup.mail.pas.earthlink.net [207.217.120.49]) by mx1.FreeBSD.org (Postfix) with ESMTP id 477A743E6E for ; Tue, 13 Aug 2002 16:24:06 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0032.cvx40-bradley.dialup.earthlink.net ([216.244.42.32] helo=mindspring.com) by scaup.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 17el12-0000Yd-00; Tue, 13 Aug 2002 16:23:57 -0700 Message-ID: <3D5994D7.E047294C@mindspring.com> Date: Tue, 13 Aug 2002 16:23:03 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: hiten@uk.FreeBSD.org Cc: freebsd-hackers@FreeBSD.org Subject: Re: SysV IPC related question References: <20020813153123.A41757@angelica.unixdaemons.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hiten Pandya wrote: > I was wondering why we have a struct mymsg in , when many > utilities defined their own version of it. I am curious about this > because our stock version of struct mymsg: > > struct mymsg { > long mtype; /* message type */ > char mtext[1]; /* message body */ > }; > > Why do we have a value of [1] in the mtext array? Are we meant to > define a struct mymsg at all!? This is the message contents. It is an overlay structure. The [1] is the same thing that, in the current ANSI C standard, you would define in terms of [0]. The point is that you have a structure that sonsists of a long followed by an indeterminate number of bytes. You cast the combination to a pointer to a structure of this type, and you can reference the long as mymsgp->mtype, and the contents as mymsgp->mtype. Please leave it alone. 8-). -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message