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