Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!ux1.lbl.gov!beard From: beard@ux1.lbl.gov (Patrick C Beard) Newsgroups: comp.sys.mac.programmer Subject: Re: LightSpeed C returning a pascal structure Message-ID: <1315@helios.ee.lbl.gov> Date: 25 Nov 88 23:51:40 GMT References: <2583@munnari.oz> Sender: usenet@helios.ee.lbl.gov Reply-To: beard@ux1.lbl.gov (Patrick C Beard) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 31 In article <2583@munnari.oz> iand@munnari.oz (Ian Robert Dobson) writes: >I am writing a program which utilises the list manager and have run into >problems using LightSpeed C (3.0). The toolbox routine: > Function LLastClick (lHandle : ListHandle) : Cell; >would logically translate to: > pascal Cell LLastClick(ListHandle lHandle) > >However LSC doesn't seem to want to return a non-integral pascal data type, >so the routine is defined in the #include file as returning a 'long'. >Furthermore, the type conversion between a long and a point gives me a 'bad >cast' error, even though they are the same size. Does anybody have a solution >to obtaining the cell (point) without manually converting the types by >splitting the long in C code. > >Ian R. Dobson >University of Melbourne >munnari.oz!iand Here's the hack I use: /* To convert a long to a Cell (which is really just a Point) */ Cell theCell; long theLastClick; theLastClick=LLastClick(listH); theCell=*(Cell*)&theLastClick; /* yech but it works! */ I hope this helps. Patrick Beard Lawrence Berkeley Laboratory