On Jan 7, 2009, at 3:32 AM, Urs Hunkeler wrote:

> Hi Antonio,
>
>> In my TinyOS application I have to use together TinyOS variables with
>> type
>> like "uint16_t" and C variables with type like "unsigned int".
>> I see they live together with no problems.
>>
>> Now, my question is: what is the difference between these two  
>> types of
>> variables in TinyOS?
>
> In C, int is machine dependent. So depending on the word size of your
> processor, an int might have different sizes. Not sure whether the
> example is actually true: on a MicaZ (using an 8-bit Atmel
> microcontroller) and int might be 8 bits, while on a TelosB (using a
> 16-bit MSP430 microcontroller) the size of the int would be 16 bits.
>
> In C, not just NesC, people started to define variable types  
> independent
> of the machine (I think, on a PC you find these things in types.h or
> inttypes.h). They usually look something like uint16 or uint16_t.  
> If you
> look at the actual definition of these types, they just map to the
> corresponding machine dependent types. So uin16_t for MicaZ might be
> mapped to long int while on a TelosB it might be simply mapped to int.
> In any case you have the guarantee that the variable uses exactly  
> 16 bits.

Correct. Although it turns out int is 16 bits on both msp430 and  
atm128 chips. But one place it's not 16 bits is TOSSIM. There were  
lots of cases in early TinyOS code where there would be overflow bugs  
that didn't show up in TOSSIM, or where packet formats might be  
different across platforms.

Another example of this is the imote2: ints are 32 bits.

Phil
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to