0
我要赶管道()系统调用,所以我改变了pipe.c源代码Linux内核编程
static pipe_hook_t pipe_hook;
pipe_hook_t set_pipe_hook(pipe_hook_t hook)
{
pipe_hook_t old_hook = pipe_hook;
pipe_hook = hook;
printk(KERN_INFO, "pipe hook: %p", hook);
return old_hook;
}
EXPORT_SYMBOL_GPL(set_pipe_hook);
然后我试图定义文件syscalls.h pipe_hook_t(包含在pipe.c )
typedef void (*pipe_hook_t)(int *filedes);
pipe_hook_t set_pipe_hook(pipe_hook_t hook);
,我有错误:
fs/pipe.c:1130: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pipe_hook’
fs/pipe.c:1131: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘set_pipe_hook’
fs/pipe.c:1138: error: ‘set_pipe_hook’ undeclared here (not in a function)
fs/pipe.c:1138: warning: type defaults to ‘int’ in declaration of ‘set_pipe_hook’
fs/pipe.c: In function ‘sys_pipe2’:
fs/pipe.c:1153: error: ‘pipe_hook’ undeclared (first use in this function)
fs/pipe.c:1153: error: (Each undeclared identifier is reported only once
fs/pipe.c:1153: error: for each function it appears in.)
fs/pipe.c:1154: error: implicit declaration of function ‘pipe_hook’
我一直在努力,也创造我自己的.h文件并定义pipe_hook_t但呃ror是一样的
如果你在'set_pipe_hook()'实现之前声明typedef,你还会得到错误吗?它看起来像缺少'typedef'可能是由于条件编译? – 2013-04-07 14:36:23