Date: Tue, 13 Aug 2002 16:23:03 -0700 From: Terry Lambert <tlambert2@mindspring.com> To: hiten@uk.FreeBSD.org Cc: freebsd-hackers@FreeBSD.org Subject: Re: SysV IPC related question Message-ID: <3D5994D7.E047294C@mindspring.com> References: <20020813153123.A41757@angelica.unixdaemons.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Hiten Pandya wrote: > I was wondering why we have a struct mymsg in <sys/msg.h>, 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D5994D7.E047294C>