LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 12-13-2001, 10:42 AM   #1
aliyildiz
LQ Newbie
 
Registered: Nov 2001
Posts: 8

Rep: Reputation: 0
Unhappy module compilation


hi all
i am trying to compile a simple.c module but many errors and
warnings occur during compilation, can anyone explain this ? thanx for helps

/* simple.c gcc -c simple.c */
#define MODULE
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>


int simple_open(struct inode *inode,struct file *filp)
{ MOD_INC_USE_COUNT; return 0; }
int simple_release(struct inode *inode, struct file *filp)
{ MOD_DEC_USE_COUNT; return 0; }

struct file_operations simple_Fops = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
simple_open,
NULL,
simple_release
};


int init_module(void)
{
int result;
result=register_chrdev(123,"proje",&simple_Fops);

printk("<1>Hello, world - this is the kernel speaking\n"); return 0;
}

void cleanup_module(void)
{
int result;

result=unregister_chrdev(123,"proje");

printk("<1>Short is the life of an LKM\n");
}



************************
hello.c:8: warning: `struct file' declared inside parameter list
hello.c:8: warning: its scope is only this definition or declaration, which is probably not what you want.
hello.c:8: warning: `struct inode' declared inside parameter list
hello.c:10: warning: `struct file' declared inside parameter list
hello.c:10: warning: `struct inode' declared inside parameter list
hello.c:13: variable `simple_Fops' has initializer but incomplete type
hello.c:14: warning: excess elements in struct initializer
hello.c:14: warning: (near initialization for `simple_Fops')
hellowarning: excess elements in struct initializer
hello.c:15: warning: (near initialization for `simple_Fops')
hello.c:16: warning: excess elements in struct initializer
hello.c:16: warning: (near initialization for `simple_Fops')
hello.c:17: warning: excess elements in struct initializer
hello.c:17: warning: (near initialization for `simple_Fops')
hello.c:18: warning: excess elements in struct initializer
hello.c:18: warning: (near initialization for `simple_Fops')
hello.c:19: warning: excess elements in struct initializer
hello.c:19: warning: (near initialization for `simple_Fops')
hello.c:20: warning: excess elements in struct initializer
hello.c:20: warning: (near initialization for `simple_Fops')
hello.c:21: warning: excess elements in struct initializer
hello.c:21: warning: (near initialization for `simple_Fops')
hello.c:22: warning: excess elements in struct initializer
hello.c:22: warning: (near initialization for `simple_Fops')
hello.c:24: warning: excess elements in struct initializer
hello.c:24: warning: (near initialization for `simple_Fops')
*****************************
 
Old 12-14-2001, 03:17 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 46
Try adding:

#define __KERNEL__
 
Old 12-14-2001, 10:11 AM   #3
aliyildiz
LQ Newbie
 
Registered: Nov 2001
Posts: 8

Original Poster
Rep: Reputation: 0
Unhappy

yes i've added but didnt work
 
Old 12-14-2001, 10:17 AM   #4
isajera
Senior Member
 
Registered: Jun 2001
Location: San Antonio, TX
Distribution: distro? what's a distro?
Posts: 1,635

Rep: Reputation: 45
you need a few flags on the gcc when compiling... here's a makefile:

#Makefile for a module

CC=gcc
MODFLAGS := -Wall -DMODULE -D__KERNEL _DLINUX

simple.o: simple.c /usr/include/linux/version.h
$(CC) $(MODFLAGS) -c simple.c
 
Old 12-15-2001, 05:39 AM   #5
aliyildiz
LQ Newbie
 
Registered: Nov 2001
Posts: 8

Original Poster
Rep: Reputation: 0
Unhappy

yes i tried , but -D__KERNEL__ flag cause many errors in <linux/fs.h> header and also added <lnux/version.h> but yet it didnt work , thanx for helps.
 
Old 03-31-2003, 03:57 AM   #6
ramanDS
LQ Newbie
 
Registered: Mar 2003
Posts: 1

Rep: Reputation: 0
i am facing the same problem of incomplete type did u get the solution
 
Old 03-31-2003, 03:11 PM   #7
kaiserfro
LQ Newbie
 
Registered: Mar 2003
Posts: 10

Rep: Reputation: 0
If your interested in creating modules or drivers, the best book I've found is:

http://www.xml.com/ldd/chapter/book/index.html

Rubini's Linux Device Drivers Rev2

Great book, should be able to show you a simple module.

Jeff
 
  


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 On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Module Compilation thirumalai Linux - Software 0 08-13-2004 12:20 AM
Apache module compilation problem the-chains Linux - Software 1 07-22-2004 11:20 AM
kernel module compilation zbrox Linux - Software 1 01-28-2004 03:31 PM
NICdriver/module compilation problem pPcG5 Linux - Networking 0 09-11-2003 05:10 AM
module compilation aliyildiz Linux - General 0 12-08-2001 01:53 PM


All times are GMT -5. The time now is 11:22 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration