Path: utzoo!attcan!uunet!seismo!dimacs.rutgers.edu!mips!zaphod.mps.ohio-state.edu!sdd.hp.com!ucsd!ucbvax!mtxinu!sybase!sisyphus!dg From: dg@sisyphus.sybase.com (David Gould) Newsgroups: comp.sys.mac.programmer Subject: Re: Color PixMap, the Clut and Think C Problem Summary: Need an lvalue Keywords: C Message-ID: <11228@sybase.sybase.com> Date: 9 Oct 90 19:21:09 GMT References: <61078@iuvax.cs.indiana.edu> <15524@reed.UUCP> <20912@well.sf.ca.us> <1990Oct3.212324.12977@axis.dsg.ti.com> <380@goya.dit.upm.es> <12464@crdgw1.crd.ge.com> Sender: news@Sybase.COM Followup-To: comp.sys.mac.programmer Organization: Sybase, Inc. Lines: 31 In article sr0o+@andrew.cmu.edu (Steven Ritter) writes: >I ran into the same problem. This seems to be a bug in the Think C >compiler. If you code it as: > err = HandToHand((Handle *)(&ourCMHandle)); >instead of > err = HandToHand(&((Handle)ourCMHandle)); >it works, even though, to my eyes, the expressions should be the same. This is not a bug, although one could reasonably argue that the compiler should disallow it. The two expressions are completely different in meaning, and the second one does not make sense, so it is no suprise that it doesn't work. (Handle *)(&ourCMHandle) means "take the address of ourCMHandle, and cast the resultant pointer into a Handle pointer" &((Handle)ourCMHandle) means "cast (ie possibly convert) ourCMHandle into a Handle, and then take the address of the result" The problem with the second expression is that the result of the cast '(Handle)ourCMHandle' is not an lvalue, and you cannot take the address of or assign to anything that is not an lvalue. That is, it does not have an address or any defined defined storage. For example, it might be in a register. - dg ------ All opinions are mine and may or may not represent Sybase Inc. ------ David Gould dg@sybase.com {sun,lll-tis,pyramid,pacbell}!sybase!dg (415) 596-3414 6475 Christie Ave. Emeryville, CA 94608