为什么在内核编程中使用u8 u16 u32 u64代替unsigned int [英] why is u8 u16 u32 u64 used instead of unsigned int in kernel programming

查看:867
本文介绍了为什么在内核编程中使用u8 u16 u32 u64代替unsigned int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到内核代码中使用了u8 u16 u32 u64数据类型.我想知道为什么需要使用u8u16u32u64而不是unsigned int?

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?

推荐答案

通常在靠近硬件工作或试图控制数据结构的大小/格式时,您需要精确控制整数的大小.

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.

对于u8uint8_t,这仅仅是因为Linux早于<stdint.h>在C语言中可用,从技术上讲,它是一种C99主义,但是以我的经验,即使是在ANSI-中,大多数现代编译器也可以使用它. C/C89模式.

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.

这篇关于为什么在内核编程中使用u8 u16 u32 u64代替unsigned int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆