C 调用函数指针创建双重声明符号错误
**编辑:发生问题是因为我在函数后面声明了变量** 因此,调用函数指针时出现以下错误:C 调用函数指针创建双重声明符号错误,c,C,**编辑:发生问题是因为我在函数后面声明了变量** 因此,调用函数指针时出现以下错误: redeclared as different kind of symbol asmlinkage long (*orig_read122) (unsigned int fd, char __user *buf, size_t count); 但是这个符号不是define tweep infect,当我删除对指针的调用时,错误就被删除了 这 我的代码 所以问题是这样的: int some_function(
redeclared as different kind of symbol
asmlinkage long (*orig_read122) (unsigned int fd, char __user *buf, size_t count);
但是这个符号不是define tweep infect,当我删除对指针的调用时,错误就被删除了
这
我的代码
所以问题是这样的:
int some_function()
{
char buf[1];
orig_read122(0, buf, 1);
}
asmlinkage long (*orig_read122) (unsigned int fd, char __user *buf, size_t count);
int my_function(unsigned int reg,char __user *wich,size_t count)
{
orig_read122(reg,wich,count);
}
其中org\u read122
在定义之前使用。隐式声明是一种非常糟糕的做法,通常会导致未定义的行为(int
和void*
的大小不再相同),但在这个cae中,代码没有编译,因为隐式声明与显式声明不匹配
解决方法是将
orig_read122
的定义移到文件顶部。我们希望您为orig_read122分配了一些功能。不是吗?这是一个伪代码,因为我的_函数中缺少“;”终止?@RachidK。不抱歉,我在编写部分代码时删除了它here@EOF我想是的,这与这个错误有关吗?orig_read122的另一个定义是什么?如果调用是这样做的:(*orig_read122)(0,buf,1),编译器会发出一个错误,说orig_read122未声明。
int some_function()
{
char buf[1];
orig_read122(0, buf, 1);
}
asmlinkage long (*orig_read122) (unsigned int fd, char __user *buf, size_t count);
int my_function(unsigned int reg,char __user *wich,size_t count)
{
orig_read122(reg,wich,count);
}