uint question

Looking at Raw IR decoder sketch, I see these 2 declaration lines: uint16_t pulses[100] [2]; uint8_t currentpulse = 0;

What is the definition of uint? What is the _t? What do the 8 and 16 refer to, bits, bytes, ?


Unsigned integer, either 8 or 16 bits.

uint8_t and uint16_t are C/C++ data types. They are declared for the AVR as:

typedef unsigned char uint8_t;
typedef unsigned int uint16_t;

They are declared in stdint.h which is supplied with the compiler. These typedefs are essentially aliases. This allows you to use uint8_t rather than unsigned char and uint16_t instead of unsigned int

The 8, 16 or the _t are not special in themselves as the typedef is for the full name. By convention, many typedefs use _t in their name.

These declarations can vary depending on the processor but they are declared such that uint8_t will give you and unsigned 8 bit value and uint16_t will give you a 16 bit value.

The value of these is for multi byte values. For example, the uint16_t will always give you a 16 bit unsigned value where as unsigned int, might give you a 16 bit value or a 32 bit value depending on the processor.

One of things that these types do not solve is endian. The endian of the value is based on the processor type. So a uint16_t on an AVR or intel processor is a little endian value but on a motorola processor it will be a big endian value.

--- bill

Try stdint.h.

"_t" signifies that it is a type.