我尝试导入 file_operations 的结构并收到此错误:
Variable has incomplete type 'struct file_operations'
我的进口是
#include <linux/kernel.h> /* We're doing kernel work */
#include <linux/module.h> /* Specifically, a module */
#include <linux/fs.h> /* for register_chrdev */
#include "sys/types.h"
错误出现在 fops:
struct file_operations Fops =
{
.owner = THIS_MODULE, // Required for correct count of module usage. This prevents the module from being removed while used.
.read = device_read,
.write = device_write,
.open = device_open,
.release = NULL
};
最少的代码:
#include <linux/kernel.h> /* We're doing kernel work */
#include <linux/module.h> /* Specifically, a module */
#include <linux/fs.h> /* for register_chrdev */
#include "sys/types.h"
struct file_operations Fops =
{
.owner = THIS_MODULE, // Required for correct count of module usage. This prevents the module from being removed while used.
.read = device_read,
.write = device_write,
.open = device_open,
.release = NULL
};