- Joined
- Jul 4, 2009
- Messages
- 16,489
- Helped
- 5,157
- Reputation
- 10,347
- Reaction score
- 5,207
- Trophy points
- 1,393
- Location
- Aberdyfi, West Wales, UK
- Activity points
- 139,505
The 'typedef' in the stdint.h just gives a nickname to 'unsigned char' so it can be called 'unit8_t', the two terms become interchangeable. The more common use of a typedef is to give a meaningful name to a complex data structure where it would be tedious to type the whole structure definition each time.
Don't worry about the bitwise operations, whether they are uint8_t or unsigned char they work exactly the same.
If you are unfamiliar with the data types, you can assume 'char' is any 8-bit value, it doesn't have to be printable. Similarly 'int' is any 16-bit value. The signed/unsigned declarations just alert the compiler that the most significant bit may be used as a polarity indicator (MSB = 1 means negative) in math operations but for bitwise operations it doesn't matter. Technically, the size of char/int/float variables depends on the size of the processors data bus, that's why there may be a specific size assigned to them somewhere, otherwise code would not be portable between different processor structures.
Brian.
edit: Horace1 beat me to it. As they advise, the 'sizeof' directive wil return the actual size of a variable or structure so you can interrogate the compiler to see what it has allocated if you want to.
Don't worry about the bitwise operations, whether they are uint8_t or unsigned char they work exactly the same.
If you are unfamiliar with the data types, you can assume 'char' is any 8-bit value, it doesn't have to be printable. Similarly 'int' is any 16-bit value. The signed/unsigned declarations just alert the compiler that the most significant bit may be used as a polarity indicator (MSB = 1 means negative) in math operations but for bitwise operations it doesn't matter. Technically, the size of char/int/float variables depends on the size of the processors data bus, that's why there may be a specific size assigned to them somewhere, otherwise code would not be portable between different processor structures.
Brian.
edit: Horace1 beat me to it. As they advise, the 'sizeof' directive wil return the actual size of a variable or structure so you can interrogate the compiler to see what it has allocated if you want to.