[Tinyos-help] CTP header field

Giuseppe Cardone giuseppe.cardone at unibo.it
Fri Nov 19 08:28:27 PST 2010


Please refrain from sending the same question multiple times to the mailing 
list in such a short timespan.

On Friday 19 November 2010 15:58:55 wasif masood wrote:
> There is no explicit declaration for data in CTP header,yet forwarding
> works, can someone please please explaiin this????????????
> typedef nx_struct {


>   nx_uint8_t (COUNT(0) data)[0]; // Deputy place-holder, field will
> probably be removed when we Deputize Ctp
> } ctp_data_header_t;

The field for CTP data is right there:

nx_uint8_t (COUNT(0) data)[0];

As the comment says the deputy[1] COUNT token can be ignored, thus that 
definition is equivalent to:

nx_uint8_t data[0];

This is a so called "flexible array", a feature of GNU C [2], extremely 
similar to "flexible array members", a feature of C99. Basically it is just a 
placeholder that tells to the compiler: here goes more data. The main catch of 
flexible array members is that they can only appear as last member in a struct 
(this restriction is due to the need of the compiler to know the offset of all 
members of the struct). Except for this, flexible arrays can be used as normal 
arrays. For more details about flexible arrays, please refer to [2].

Hope this helps.

[1] http://deputy.cs.berkeley.edu/
[2] http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Zero-Length.html

Giuseppe Cardone, Ph.D. Student
DEIS-LIA - Università degli Studi di Bologna
E-mail: giuseppe.cardone at unibo.it
Web: http://lia.deis.unibo.it/Staff/GiuseppeCardone/

More information about the Tinyos-help mailing list