Reputation: 44305
I have a Linux standard header file e.g.
/usr/src/linux-headers-3.2.0-35/include/linux/usbdevice_fs.h
which contain define
statements as follows:
#define USBDEVFS_SUBMITURB32 _IOR('U', 10, struct usbdevfs_urb32)
#define USBDEVFS_DISCARDURB _IO('U', 11)
#define USBDEVFS_REAPURB _IOW('U', 12, void *)
What does '_IOR', '_IO' and '_IOW' mean? What value is actually given e.g. to USBDEVFS_DISCARDURB
?
Upvotes: 11
Views: 11149
Reputation: 3029
They define ioctl numbers, based on ioctl function and input parameters.
The are defined in kernel, in include/asm-generic/ioctl.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
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.
Upvotes: 9
Reputation: 4366
These are also macros defined elsewhere.
In general if you want to see your code after pre-processor has been computed use
gcc -E foo.c
this will output your code pre-processed
For example:
foo.c
#define FORTY_TWO 42
int main(void)
{
int foo = FORTY_TWO;
}
will give you with gcc -E foo.c
:
int main(void)
{
int foo = 42;
}
Upvotes: 1