'+=' : left operand must be l-value

Hi,

I was trying to increment a (void *) type variable, as shown below. However, I got compiling error message under Windows Visual C/C++ 2003. It doesn't seem to be a problem at Linux.

Anyone can give me some suggestions ?

- my code:
void *tmp = 0;
(unsigned char*)tmp += 1;


- my error:
error C2106: '+=' : left operand must be l-value

Thanks,
-Leo
The particular operating system doesn't matter.
What matters is the compiler and whether the code is legal c++.
The code you give isn't right (and I don't believe that it compiled using a compiler on linux).

This will work:
1
2
void *tmp = 0;
tmp = (unsigned char*)tmp + 1;


Topic archived. No new replies allowed.