I’ve got void pointer which I want to do pointer arithmetic on it.
to do so, I want to cast it to a char pointer.
( char * ) buf += current_size;
However when I do so, I get the following error:
error: lvalue required as left operand of assignment
I tried also adding parenthesis on the the whole left side, with no success.
Why do I get this ?
You can avoid the warning by writing the assignment operator out:
Part of the reason you get the warning is that
sizeof(void)is undefined and you cannot do arithmetic onvoid *. Beware: GCC has an extension whereby it treats the code as ifsizeof(void) == 1, but that is not in the C standard.The cast on the LHS of the assignment has no effect on the assignment.