LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 04-06-2008, 02:34 AM   #1
saffari62
LQ Newbie
 
Registered: Apr 2008
Posts: 1

Rep: Reputation: 0
error :variable fops has initializer but incomplete type in compile device driver


HI,
I am writing char device driver and get int troubles while compiling module with gcc -c test.c.

Error reported from compiler is: error:
func1.c:181: error: variable ‘fops’ has initializer but incomplete type
func1.c:182: error: unknown field ‘read’ specified in initializer
func1.c:182: warning: excess elements in struct initializer
func1.c:182: warning: (near initialization for ‘fops’)
func1.c:183: error: unknown field ‘write’ specified in initializer
func1.c:183: warning: excess elements in struct initializer
func1.c:183: warning: (near initialization for ‘fops’)
func1.c:184: error: unknown field ‘open’ specified in initializer
func1.c:184: warning: excess elements in struct initializer
func1.c:184: warning: (near initialization for ‘fops’)
func1.c:185: error: unknown field ‘release’ specified in initializer
func1.c:185: warning: excess elements in struct initializer
func1.c:185: warning: (near initialization for ‘fops’)
func1.c:186: error: unknown field ‘ioctl’ specified in initializer
func1.c:187: warning: excess elements in struct initializer
func1.c:187: warning: (near initialization for ‘fops’)


source code :::::::::::::::

struct file_operations fops = {
.read = readf,
.write =writef,
.open = openf,
.release = releasef,
.ioctl = ioctlf
};
 
Old 04-06-2008, 01:53 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
A couple points:
  1. You have to have the correct headers included so that struct file_operations is declared.
  2. You should use a kernel Makefile so that the appropriate headers are in the include path. Instructions for doing this are in any up-to-date linux 2.6 kernel module guide or howto.

Last edited by osor; 04-06-2008 at 02:24 PM.
 
  


Reply



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
tai64nlocal.c:55: error: dereferencing pointer to incomplete type ExCIA Linux - General 1 03-31-2009 09:49 AM
error: field has incomplete type halturata Programming 4 04-11-2008 05:01 PM
incomplete type error using cpp with gcc aatwell Programming 8 11-04-2007 11:12 AM
error: dereferencing pointer to incomplete type ChullDouvre Programming 2 05-02-2007 12:16 AM
Error: dereferencing pointer to incomplete type cynthia_thomas Programming 1 05-01-2006 08:10 AM

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

All times are GMT -5. The time now is 06:29 PM.

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