why is u8 u16 u32 u64 used instead of unsigned int in kernel programming

user966588 picture user966588 · Jun 17, 2015 · Viewed 81.8k times · Source

I see u8 u16 u32 u64 data types being used in kernel code. And I am wondering why is there need to use u8 or u16 or u32 or u64 and not unsigned int?

Answer

Brian McFarland picture Brian McFarland · Jun 17, 2015

Often when working close to the hardware or when trying to control the size/format of a data structure you need to have precise control of the size of your integers.

As for u8 vs uint8_t, this is simply because Linux predated <stdint.h> being available in C, which is technically a C99-ism, but in my experience is available on most modern compilers even in their ANSI-C / C89 modes.