LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-18-2008, 06:56 AM   #1
rajkumar_halle
LQ Newbie
 
Registered: Aug 2008
Posts: 2

Rep: Reputation: 0
error: variable ‘scull_fops’ has initializer but incomplete type


Please reply me regarding this errors.
the source code and the error file are as below.

#define MODULE
#include <linux/module.h>
#include<linux/fs.h>
#include<linux/kernel.h>
#include<linux/slab.h>
//#include<linux/ioctl.h>
//#include</usr/include/error.h>
MODULE_LICENSE("GFP_KERNEL");
#define MAJ_NUM 45
#define READ 5
#define WRITE 6
#define DEVICE_NAME "raj"

unsigned long *test;

int scull_open(struct inode *inode, struct file *file)
{
printk("In open function\n");
// MOD_INC_USE_COUNT;
return 0;
}

int scull_release(struct inode *inode, struct file *file)
{
printk("In Release function \n");
// MOD_DEC_USE_COUNT;
}



struct file_operations *f_op;
struct file_operations scull_fops = {
.open = scull_open,
.release = scull_release,
};



int init_module(void)
{
unsigned long result;
result=register_chrdev(MAJ_NUM,"raj",&f_op);
if(result <0)
{
printk("Can't get Major number %d\n",MAJ_NUM);
return result;
}
if(MAJ_NUM==0) MAJ_NUM=result;


printk("Hello \n");
test=(unsigned long *)kmalloc(1024*5,"GFP_KERNEL");
printk("test=%x",&test);
return 0;
}

void cleanup_module(void)
{
unregister_chrdev(MAJ_NUM,"raj");
printk("Cleanup Over \n");
}


new.c:7:23: error: linux/slab.h: No such file or directory
new.c:18: warning: ‘struct file’ declared inside parameter list
new.c:18: warning: its scope is only this definition or declaration, which is probably not what you want
new.c:18: warning: ‘struct inode’ declared inside parameter list
new.c:25: warning: ‘struct file’ declared inside parameter list
new.c:25: warning: ‘struct inode’ declared inside parameter list
new.c:34: error: variable ‘scull_fops’ has initializer but incomplete type
new.c:35: error: unknown field ‘open’ specified in initializer
new.c:35: warning: excess elements in struct initializer
new.c:35: warning: (near initialization for ‘scull_fops’)
new.c:36: error: unknown field ‘release’ specified in initializer
new.c:36: warning: excess elements in struct initializer
new.c:36: warning: (near initialization for ‘scull_fops’)
new.c: In function ‘init_module’:
new.c:50: error: invalid lvalue in assignment
[root@localhost check]#
 
Old 08-19-2008, 12:51 AM   #2
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
Shouldn't there be a space in between #include and <linux/slab.h> ? - as in:
#include <linux/module.h>
This should also be fixed for the 2-nd through 6-th #include lines.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
error: array type has incomplete element type duduarbel Programming 8 05-27-2008 12:25 PM
error: array type has incomplete element type nasim751 Linux - Software 1 04-14-2008 09:02 PM
error :variable fops has initializer but incomplete type in compile device driver saffari62 Programming 1 04-06-2008 01:53 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration