Issue
While browsing linux networking code, I came across these datatypes:
- u8
- uint8_t
- __u8
- __be8
(same things for 16, 32 and 64 bits)
Can someone please explain the difference between these datatypes and where to use which? I have seen the definitions of these datatypes but those were not clear to me.
Solution
uint8_t
is Standard C and represents an unsigned 8-bit integral type. If you are on a system that does not have 8-bit addressable units then this will not be defined; otherwise it is probably a typedef
for unsigned char
.
Anything with __
in it is reserved for implementation use. This means that compiler writers and standard library writers can use those identifiers without worrying about a name clash with user code. You may see this when looking in the internals of standard library implementation.
u8
is non-standard but almost certainly means the same as uint8_t
. A reason that u8
might be used is in code that was written before uint8_t
was added to Standard C.
Answered By - M.M Answer Checked By - Gilberto Lyons (WPSolving Admin)