[Tinyos-help] assigning a unsized array

Romain Thouvenin romain.thouvenin at gmail.com
Fri May 18 05:39:49 PDT 2007


Hi,

I have made a TLV packet with the following declaration :
typedef nx_struct sensing_msg {
  nx_uint8_t flags;
  nx_uint8_t length;
  nx_uint8_t value[];
} sensing_msg_t;

I used [] instead of a pointer, because I need to mig the packet in
java and a pointer won't work. In my nesC application, when I receive
the packet, I would like to avoid a copy of the payload, so I naïvely
tried :
sensing_msg_t * sm = payload;

But of course It does not work, payload[2] is assigned to value, not value[0].
So I tried then :
sm->value = payload + 2

But this does not compile, even if I cast value into a pointer.

Am I obliged to copy the payload here, or is there another trick I
didn't think of ?

Thanks for your help,

Romain


More information about the Tinyos-help mailing list