This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
user-space works kernel-space compile fails ?
- From: Der Herr Hofrat <der dot herr at mail dot hofr dot at>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 23 Dec 2002 10:34:14 +0100 (CET)
- Subject: user-space works kernel-space compile fails ?
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;
}