Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

error: assigning to 'subhook_t' (aka 'subhook_struct *') from incompatible type 'void *'

I’ve solved 6 different errors, but no matter how far I look I keep hitting a dead end with this one error in a subhook code written in c.

./subhook_x86.c:470:10: error: assigning to 'subhook_t' (aka 'subhook_struct *') from incompatible type 'void *'
  hook = calloc(1, sizeof(*hook));
         ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

For context, hook is declared as
subhook_t hook;

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Unlike C, C++ doesn’t allow automatic conversions to and from void *. You need to use an explicit cast.

hook = static_cast<subhook_t>(calloc(1, sizeof(*hook)));
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading