Definition of uint8_t

I would expect uint8_t to be typedefed to unsigned char. However in stdint.h it appears that this is the case only if DOXYGEN is defined.

Otherwise it is defined:
typedef int int8_t attribute((mode(QI)));
which will make it a 16 bit quantity.

If it is any help I am using Eclipse.

Sorry if this has been asked before but I am new to Arduino and could not find any previous explanation.

Otherwise it is defined:
typedef int int8_t attribute((mode(QI)));

Nope, wrong line: typedef unsigned int uint8_t __attribute__((__mode__(__QI__)));

An integer with no specified size is compiler specific on its actual size. By default it's "short int" on avr-gcc. However, the attribute((mode(..))) entry specifies a size:

QI: An integer that is as wide as the smallest addressable unit, usually 8 bits.
HI: An integer, twice as wide as a QI mode integer, usually 16 bits.
SI: An integer, four times as wide as a QI mode integer, usually 32 bits.
DI: An integer, eight times as wide as a QI mode integer, usually 64 bits.
SF: A floating point value, as wide as a SI mode integer, usually 32 bits.
DF: A floating point value, as wide as a DI mode integer, usually 64 bits.

So with QI in there it's 8 bits.

You can think of it as seen from a 32-bit perspective -
Quarter Int
Half Int
Single Int
Double Int
Single Float
Double Float

However, the attribute((mode(..))) entry specifies a size:
That explains it. I clearly need to get to grips with gcc (or g++). Where is the best place to look?

Roger_Woollett:

However, the attribute((mode(..))) entry specifies a size:
That explains it. I clearly need to get to grips with gcc (or g++). Where is the best place to look?

The GCC manuals are at GCC online documentation - GNU Project.

If you are using the GCC that comes with the IDE, you need to scroll down to get to the 4.3 version (4.3.2 is the version currently used by the IDE, but 4.3.6 should be close enough). In general, the normal user should not need attribute((mode_(...))), but these are used by the library to make sure things are certain sizes.

The gcc in the release does provide the stdint.h file from the C-99 standard. This standard header, provides things like int8_t, etc. for types of specific sizes. It provides int_fast_t types, etc. for types that are at least bits, but should be fast (on many RISC platforms, it is faster to do arithmetic in int/long sizes and not for short types). It provides int_least_t types for types that are at least bits. <stdint.h>.

Thanks for all that. Not only am I new to arduino but I have not done any serious C++ since I retired 11 years ago (and that was VC++). I have a bit of a learning curve to deal with but that was very helpful.