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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message