Linux中的C标头中的'_IO(...)'是什么意思? [英] What does '_IO(...)' mean in C headers in Linux?

查看:160
本文介绍了Linux中的C标头中的'_IO(...)'是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Linux标准头文件,例如

I have a Linux standard header file e.g.

/usr/src/linux-headers-3.2.0-35/include/linux/usbdevice_fs.h

其中包含 define 语句如下:

#define USBDEVFS_SUBMITURB32       _IOR('U', 10, struct usbdevfs_urb32)
#define USBDEVFS_DISCARDURB        _IO('U', 11)
#define USBDEVFS_REAPURB           _IOW('U', 12, void *)

_ IOR, _ IO和 _IOW是什么意思?实际上给出了什么值,例如到 USBDEVFS_DISCARDURB

What does '_IOR', '_IO' and '_IOW' mean? What value is actually given e.g. to USBDEVFS_DISCARDURB?

推荐答案

它们基于ioctl函数定义ioctl数字和输入参数。
是在内核中定义的,位于 include / asm-generic / ioctl.h 中。

They define ioctl numbers, based on ioctl function and input parameters. The are defined in kernel, in include/asm-generic/ioctl.h.

您需要包括< linux / ioctl.h> (或 linux / asm-generic / ioctl.h )。在包含

/usr/src/linux-headers-3.2.0-35/include/linux/usbdevice_fs.h

You need to include <linux/ioctl.h> (or linux/asm-generic/ioctl.h) in your program. Before including
/usr/src/linux-headers-3.2.0-35/include/linux/usbdevice_fs.h

您不能预编译该值(例如 USBDEVFS_DISCARDURB ),因为它们在其他平台上可能会有所不同。例如,您正在普通的旧x86上开发代码,但是有人会尝试在x86_64 / arm / mips / etc上使用它。因此,您应始终包含内核的 ioctl.h ,以确保使用的是正确的值。

You can't "precompile" this values (e.g. USBDEVFS_DISCARDURB), because they can be different on other platforms. For example, you are developing your code on plain old x86, but then someone will try to use it on x86_64/arm/mips/etc. So you should always include kernel's ioctl.h to make sure, you are using right values.

这篇关于Linux中的C标头中的'_IO(...)'是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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