Let’s say you have a “void *a” and “void *ptr” that point to different addresses defined in your code. Then I was wondering if these two lines were equivalent and functionally the same?
*((unsigned **)((char*)ptr+4)) = a;
and
*((unsigned *)((char*)ptr+4)) = a;
The second one throws a warning that “assignment makes integer from pointer without a cast”
Also, would it also be the same as the above to just do?:
*((char*)ptr+4) = a;
These are not equivalent. #1 resolves
(char*)ptr+4to be a pointer to unsigned (*unsigned), while #2 resolves it to beunsigned.ais a void pointer, so it can be casted to*unsigned, but not tounsigned(implicitly), that’s why you get the warning.The #3 resolves the same to a
char, which would also yield a warning.