简体   繁体   中英

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.

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

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>)); . Your current cast hides the incorrect declaration of real_mal .

Once you've fixed that, you can just write return real_mal(size); .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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