I need help with a compile error that I am getting.
The error is:
error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
on the following line
PRINT_INDENT("Inode2 PTR: %p\n", (void *)ptr);
Context
unsigned int ptr;
memcpy(&ptr, value, sizeof(ptr));
PRINT_INDENT("Inode2 PTR: %p\n", (void *)ptr);
#define PRINT_INDENT(...) ({int __j = indent_level; while (__j-- > 0) printf(" "); printf(__VA_ARGS__);})
Are you using a 64-bit platform with 32-bit
ints? If so, the error is self-explanatory.ptris a 32-bit variable, and you’re casting it to a 64-bitvoid *. A workaround is to first cast it to anunsigned long longand then cast the result to avoid *.But why are you doing this? Why not just print
ptras anunsigned intinstead of casting it to avoid *as follows: