inotify C 头文件

发布于 2024-10-06 21:52:29 字数 264 浏览 0 评论 0原文

所以我正在尝试编写一个使用 inotify 的 C 程序。我以前使用过 pyinotify 所以我了解它是如何工作的。但是,我遵循一些指南,它告诉我包含 。问题是这个头文件只有宏定义,没有函数原型。看起来这些函数的原型是在 中。

我的问题是 linux/inotify.h 和 sys/inotify.h 之间有什么区别?为什么两者都有呢?

So I'm trying to write a C program that uses inotify. I've used pyinotify before so I understand how it works. However, I'm following some guide and it tells me to include <linux/inotify.h>. The problem is that this header only has macro definitions, not the funciton prototypes. It looks like the functions are prototyped in <sys/inotify.h>.

My question is what's the difference between linux/inotify.h and sys/inotify.h? Why are there both?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微暖i 2024-10-13 21:52:29

sys/inotify.hGNU C 库 的一部分。它公开了您的程序将使用的结构和函数,以便接收文件系统更改通知。可以认为是通知系统的公共API。

linux/inotify.h 是 Linux 内核的一部分。它定义了用于实现通知系统本身的内核结构和常量。除非您正在编写类似内核模块的内容,否则不应包含该文件,因为它是 Linux 特定的,因此不可移植。

sys/inotify.h is part of the GNU C library. It exposes the structures and functions that your program will use in order to receive filesystem change notifications. It can be considered as the public API of the notification system.

linux/inotify.h is part of the Linux kernel. It defines the kernel structures and constants used to implement the notification system itself. You shouldn't include that file unless you're writing something like a kernel module, because it's Linux-specific and thus not portable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文