简体   繁体   English

错误:空值不应该被忽略

[英]error: void value not ignored as it ought to be

I am trying to get function symbol from a dynamic library and then I need to replace my function with the library funciton using the new function pointer.The code is to be written in c++ file. 我试图从动态库中获取函数符号,然后需要使用新的函数指针将函数替换为函数库。代码将用c ++文件编写。

I used following steps, 我使用了以下步骤,

{
void *temp = dlsym(<FLAGS>,<FUNC_NAME>);
*reinterpret_cast<void**>(&real_mal) = temp;
void *p = NULL;
p = real_mal(size);
return p;
}

But at compile time I am getting this "error: void value not ignored as it ought to be " error 但是在编译时,我遇到了这个“错误:void值不应该被忽略,因为它应该是”错误

How can I resolve above situation ? 如何解决以上情况?

Thanks 谢谢

Joachim's comment is right. 约阿希姆的评论是正确的。 The first problem is actually your cast. 第一个问题实际上是您的演员表。 The proper cast is real_mal = reinterpret_cast<void*(size_t)>(dlsym(<FLAGS>,<FUNC_NAME>)); 正确的转换为real_mal = reinterpret_cast<void*(size_t)>(dlsym(<FLAGS>,<FUNC_NAME>)); . Your current cast hides the incorrect declaration of real_mal . 您当前的演员表隐藏了real_mal的错误声明。

Once you've fixed that, you can just write return real_mal(size); 解决此问题后,您只需编写return real_mal(size); .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM