NO

Author Topic: Problem with "Lvalue required"  (Read 3033 times)

alexei

  • Guest
Problem with "Lvalue required"
« on: September 04, 2010, 11:29:49 AM »
Other compilers are OK with this (see code below). Is it because of ANSI?
Is there a way to do such things without re-declaring variables?
I mean typecasting any variable to any type.

Code: [Select]
int main (int argc, char *argv[])
{
  unsigned z;
  void* p;
  (int)z = (int)z-5;
  (int)p = (int)p+2;
  return 0;
}
Test.c(5): error #2088: Lvalue required.
Test.c(6): error #2088: Lvalue required.

JohnF

  • Guest
Re: Problem with "Lvalue required"
« Reply #1 on: September 04, 2010, 12:47:39 PM »
Other compilers are OK with this (see code below). Is it because of ANSI?
Is there a way to do such things without re-declaring variables?
I mean typecasting any variable to any type.

Test.c(5): error #2088: Lvalue required.
Test.c(6): error #2088: Lvalue required.

The answer is no. You can sometimes cast the right side so that it matches the left side but you can never cast the left side or change a variable into a different type.

Code: [Select]
float f = 1.0;
 int i;
 i = (int)f;

John

Juni

  • Guest
Re: Problem with "Lvalue required"
« Reply #2 on: September 08, 2010, 10:06:17 AM »
Just curious wich compiler do you mean ?