Home > Mobile >  error: assigning to 'subhook_t' (aka 'subhook_struct *') from incompatible type
error: assigning to 'subhook_t' (aka 'subhook_struct *') from incompatible type

Time:08-07

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;

CodePudding user response:

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)));
  • Related