www.digitalmars.com         C & C++   DMDScript  

D - another reason to get rid C casts ... '255' is not an lvalue

reply "Mike Wynn" <mike.wynn l8night.co.uk> writes:
the following code
generates the error
mc.d(7): '255' is not an lvalue

(DMD 0.52 alpha)

void func( byte[] buf )
{
 int i=8;
 buf[1] = ((buf[i])&0xFF);
}

int main( char[][] args )
{
 int i = 8;
 int[] foo = new byte[16];
 func( foo );
 return 0;
}
Feb 05 2003
parent "Walter" <walter digitalmars.com> writes:
The trouble here is that buf[i] looks like a type. Argh.

"Mike Wynn" <mike.wynn l8night.co.uk> wrote in message
news:b1sdkp$r6i$1 digitaldaemon.com...
 the following code
 generates the error
 mc.d(7): '255' is not an lvalue

 (DMD 0.52 alpha)

 void func( byte[] buf )
 {
  int i=8;
  buf[1] = ((buf[i])&0xFF);
 }

 int main( char[][] args )
 {
  int i = 8;
  int[] foo = new byte[16];
  func( foo );
  return 0;
 }

Feb 15 2003