NOTE: This is NOT a duplicate of the billion and one questions with this name in the title. This has to do with pointers and very odd stuff, not an accidental = instead of ==.
I have a C++ function in which I have a void* argument called out. I have this line:
(char*)out=new char[*size];
Where size in a uint32_t*. The compiler complains:
fundemental_bin_types.h:55:32: error: lvalue required as left operand of assignment
What is wrong?
(char*)outis not an lvalue (outitself may be but the cast changes things), the cast belongs on the other side of the assignment and you’re casting to a void pointer rather than a char pointer:In any case,
void*is implicitly convertible from other pointers so you can get away with just: