|
|
no previous prototype for `init_module'
hi all:
i followed the <The Linux Kernel Module Programming Guide>, and wrote a
module hello-1.c:
[code]
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk("<1>Hello world 1.\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world 1.\n");
}
[/code]
meanwhile i built a makefile:
[code]
TARGET := hello-1
WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
INCLUDE := -isystem /lib/modules/`uname -r`/build/include
CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
CC := gcc
${TARGET}.o: ${TARGET}.c
[/code]
but, when i executed the make command, i have gotten these:
[code]
hello-1.c:5: warning: no previous prototype for `init_module'
hello-1.c:12: warning: no previous prototype for `cleanup_module'
/lib/modules/2.4.20-8/build/include/asm/processor.h: In function
`copy_segments':
/lib/modules/2.4.20-8/build/include/asm/processor.h:456: warning: unused
parameter `p'
/lib/modules/2.4.20-8/build/include/asm/processor.h:456: warning: unused
parameter `mm'
/lib/modules/2.4.20-8/build/include/asm/processor.h: In function
`release_segments':
/lib/modules/2.4.20-8/build/include/asm/processor.h:457: warning: unused
parameter `mm'
/lib/modules/2.4.20-8/build/include/linux/prefetch.h: In function
`prefetch':
/lib/modules/2.4.20-8/build/include/linux/prefetch.h:43: warning: unused
parameter `x'
/lib/modules/2.4.20-8/build/include/linux/prefetch.h: In function
`prefetchw':
/lib/modules/2.4.20-8/build/include/linux/prefetch.h:48: warning: unused
parameter `x'
[/code]
what is wrong with it? who would tell me? many thanks!!!
|
|
0
|
|
|
|
Reply
|
k00kyy (1)
|
12/16/2005 2:18:38 AM |
|
Final wrote:
[]
> WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
[]
> hello-1.c:5: warning: no previous prototype for `init_module'
> hello-1.c:12: warning: no previous prototype for `cleanup_module'
[]
> what is wrong with it? who would tell me? many thanks!!!
man gcc
-Wmissing-prototypes (C only)
Warn if a global function is defined without a previous
prototype
declaration. This warning is issued even if the definition
itself
provides a prototype. The aim is to detect global functions
that
fail to be declared in header files.
|
|
0
|
|
|
|
Reply
|
Maxim
|
12/16/2005 11:40:00 AM
|
|
"Final" <k00kyy@gmail.com> wrote in message
news:dnt853$333$1@news.yaako.com...
> hi all:
> i followed the <The Linux Kernel Module Programming Guide>, and wrote a
> module hello-1.c:
> [code]
> #include <linux/module.h>
> #include <linux/kernel.h>
>
> int init_module(void)
> {
> printk("<1>Hello world 1.\n");
>
> return 0;
> }
>
> void cleanup_module(void)
> {
> printk(KERN_ALERT "Goodbye world 1.\n");
> }
> [/code]
> meanwhile i built a makefile:
> [code]
> TARGET := hello-1
> WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
> INCLUDE := -isystem /lib/modules/`uname -r`/build/include
> CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
> CC := gcc
>
> ${TARGET}.o: ${TARGET}.c
> [/code]
> but, when i executed the make command, i have gotten these:
> [code]
> hello-1.c:5: warning: no previous prototype for `init_module'
> hello-1.c:12: warning: no previous prototype for `cleanup_module'
> /lib/modules/2.4.20-8/build/include/asm/processor.h: In function
> `copy_segments':
> /lib/modules/2.4.20-8/build/include/asm/processor.h:456: warning: unused
> parameter `p'
> /lib/modules/2.4.20-8/build/include/asm/processor.h:456: warning: unused
> parameter `mm'
> /lib/modules/2.4.20-8/build/include/asm/processor.h: In function
> `release_segments':
> /lib/modules/2.4.20-8/build/include/asm/processor.h:457: warning: unused
> parameter `mm'
> /lib/modules/2.4.20-8/build/include/linux/prefetch.h: In function
> `prefetch':
> /lib/modules/2.4.20-8/build/include/linux/prefetch.h:43: warning: unused
> parameter `x'
> /lib/modules/2.4.20-8/build/include/linux/prefetch.h: In function
> `prefetchw':
> /lib/modules/2.4.20-8/build/include/linux/prefetch.h:48: warning: unused
> parameter `x'
> [/code]
> what is wrong with it? who would tell me? many thanks!!!
>
Well, your compilation options included "-Wmissing-prototypes", so it
complains because you did not provide a prototype for those functions.
Try putting the prototypes in at the top of your source file (after
#includes):
int init_module(void);
int init_module(void);
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project
|
|
0
|
|
|
|
Reply
|
Fred
|
12/16/2005 6:25:34 PM
|
|
Maxim Yegorushkin �:
> Final wrote:
>
> []
>
>
>>WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
>
>
> []
>
>
>>hello-1.c:5: warning: no previous prototype for `init_module'
>>hello-1.c:12: warning: no previous prototype for `cleanup_module'
>
>
> []
>
>
>>what is wrong with it? who would tell me? many thanks!!!
>
>
> man gcc
>
> -Wmissing-prototypes (C only)
> Warn if a global function is defined without a previous
> prototype
> declaration. This warning is issued even if the definition
> itself
> provides a prototype. The aim is to detect global functions
> that
> fail to be declared in header files.
>
thanks,i modified the source:
////////////////////////////////////////////
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void);
void cleanup_module(void);
int init_module(void)
{
printk("<1>Hello world 1.\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world 1.\n");
}
///////////////////////////////////////////////////////////////
but some warnings keep on:
//////////////////////////////////////////////////////////////
/lib/modules/2.4.20-8/build/include/asm/processor.h: In function
`copy_segments':
/lib/modules/2.4.20-8/build/include/asm/processor.h:456: warning: unused
parameter `p'
/lib/modules/2.4.20-8/build/include/asm/processor.h:456: warning: unused
parameter `mm'
/lib/modules/2.4.20-8/build/include/asm/processor.h: In function
`release_segments':
/lib/modules/2.4.20-8/build/include/asm/processor.h:457: warning: unused
parameter `mm'
/lib/modules/2.4.20-8/build/include/linux/prefetch.h: In function
`prefetch':
/lib/modules/2.4.20-8/build/include/linux/prefetch.h:43: warning: unused
parameter `x'
/lib/modules/2.4.20-8/build/include/linux/prefetch.h: In function
`prefetchw':
/lib/modules/2.4.20-8/build/include/linux/prefetch.h:48: warning: unused
parameter `x'
////////////////////////////////////////////////////////////////////////
|
|
0
|
|
|
|
Reply
|
Final
|
12/19/2005 2:26:06 AM
|
|
Final wrote:
[]
> but some warnings keep on:
Study your compiler documentation. -Wall flag turns on -Wunused.
You are not likely to modify linux headers, you only can turn the
warning off or ignore it.
|
|
0
|
|
|
|
Reply
|
Maxim
|
12/19/2005 10:58:05 AM
|
|
|
4 Replies
52 Views
(page loaded in 0.062 seconds)
|
|
|
|
|
|
|
|
|