variable type cast
T.Verhoeff at tue.nl
Mon May 13 21:06:40 CEST 2013
On Sun, May 12, 2013 at 04:12:45PM -0700, Jay Michael wrote:
> gpc version 20070904, based on gcc-3.4.5 (mingw special)
> type INT16 = INTEGER attribute( size=16 ) ;
> type WORD16 = Cardinal attribute( size=16 ) ;
> var i16 : INT16 ;
> var w16 : WORD16 ;
> why does
> WORD16(I16) := W16 ;
> produce "error: invalid lvalue in assignment"?
I would think that the reason is that to the left of the assignment
operator you need a variable or equivalent, in C jargon also known
as an lvalue (i.e. something that has a persistent memory address).
Note that a variable by itself is both an lvalue and an expression (an
rvalue, though this term is little used), but not every expression is
an lvalue (e.g. v + 1 is not an lvalue; you cannot assign anything to it).
In particular, casting is an operator that yields an rvalue, but not
an lvalue. Casting needs to done to the right of the assignment operator.
(The previous warnings about casting still stand.)
E-MAIL: T.Verhoeff (a) TUE.NL | Dept. of Math. & Comp. Science
PHONE: +31 40 247 41 25 | Eindhoven University of Technology
FAX: +31 40 247 54 04 | PO Box 513, NL-5600 MB Eindhoven
http://www.win.tue.nl/~wstomv/ | The Netherlands
More information about the Gpc