* user-space works kernel-space compile fails ?
@ 2002-12-23 3:11 Der Herr Hofrat
0 siblings, 0 replies; only message in thread
From: Der Herr Hofrat @ 2002-12-23 3:11 UTC (permalink / raw)
To: gcc-help
HI !
gcc is 2.95.3 (probably not relevant) on Linux X86 (SuSE 7.0)
this is posibly somewhat linux specific but the problem I belive lies in my
not understanding gcc - I have a array of pointers to functions returning
int -
int (*(isdn_pops[NR_FUNCS]))();
In user-space I can copile the atached example and get what I expected -
steping thrgouht the array the functions are called. Compiled with the same
flags I used for the kernel module (except the kernel spcefic defines)
gcc -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -g -pipe -mpreferred-stack-boundary=2 -march=i686 -malign-functions=4 -fomit-frame-pointer -O2 -I/usr/src/linux/include isdn_pops.c -o isdn_pops
isdn_pops.c:21: warning: function declaration isn't a prototype
isdn_pops.c:32: warning: function declaration isn't a prototype
If I try the same declaration in a Linux kernel module I get
gcc -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -g -pipe -mpreferred-stack-boundary=2 -march=i686 -malign-functions=4 -DMODULE -fomit-frame-pointer -D_LOOSE_KERNEL_NAMES -O2 -I/usr/src/linux/include -c -o pal.o pal.c
pal.c:75: warning: function declaration isn't a prototype
pal.c:76: `isdn_pops' undeclared here (not in a function)
pal.c:76: initializer element is not constant
pal.c:76: (near initialization for `__ksymtab_isdn_pops.value')
pal.c: In function `f_register':
pal.c:181: `isdn_pops' undeclared (first use in this function)
pal.c:181: (Each undeclared identifier is reported only once
pal.c:181: for each function it appears in.)
pal.c: In function `setup_isdn_pops':
pal.c:193: `isdn_pops' undeclared (first use in this function)
pal.c:190: warning: `ret' might be used uninitialized in this function
make: *** [pal.o] Error 1
The error on line 76 is from EXPORT_SYMBOL(isdn_pops) and the later error
from the f_register function that is basically the same as in the user-space
test.
any hint appreciated !
thx !
hofrat
---- user-space test that works ----
#include <stdio.h>
#define NR_FUNCS 3
int junk1(void *data){ printf("Junk 1 :%d\n",(int)data ); return 0; }
int junk2(void *data){ printf("Junk 2 :%d\n",(int)data ); return 1; }
int junk3(void *data){ printf("Junk 3 :%d\n",(int)data ); return 2; }
int (*(isdn_pops[NR_FUNCS]))();
int
f_register(void)
{
isdn_pops[0] = &junk1;
isdn_pops[1] = &junk2;
isdn_pops[2] = &junk3;
return 0;
}
int main(){
int i,arg,ret;
f_register();
for(i=0;i<NR_FUNCS;i++){
arg=i;
ret=isdn_pops[i](arg);
printf("fundtion[%d] returned %d\n",i,ret);
}
return 0;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-12-23 9:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-23 3:11 user-space works kernel-space compile fails ? Der Herr Hofrat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).