d'oh.

i knew i was doing something wrong there. and yes. K&R http://cm.bell-labs.com/cm/cs/cbook/ way to go.

Sankar.


On Sat, 18 Nov 2006 13:23:30 -0600, Michael Schippling <[EMAIL PROTECTED]> wrote:

One slight correction...
 > " the corresponding
 > bytes from m_msg.data are put into the corresponding fields in the
 > variable addressed by the pointer body."
 >
Implies that values are copied from m_msg.data to someplace, however
this is not the case. The assignment statement:
     CountMsg_t* body = (CountMsg_t*)m_msg.data;
simply sets the "body" variable to the address of the m_msg.data array.
You might think that you need to use &m_msg.data to get the address,
but "data" is declared as an array of chars and C treats the array
name (with no index -- data[1]) as a pointer to the first element.
(I think you might get away with using the &, but it's redundant...)

The key fact is that if you write to body->n you will write into m_msg.data

If the above makes no sense, probably I'm a bad explainer, but look
at the K&R C book...
MS




--
No opera plot can be sensible, for people do not sing when they are feeling sensible. - W. H. Auden

_______________________________________________
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to