Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!husc6!endor!siegel
From: siegel@endor.harvard.edu (Rich Siegel)
Newsgroups: comp.sys.mac.programmer
Subject: Re: LightSpeed C returning a pascal structure
Message-ID: <731@husc6.harvard.edu>
Date: 30 Nov 88 14:11:08 GMT
References: <2583@munnari.oz>
Sender: news@husc6.harvard.edu
Reply-To: siegel@endor.UUCP (Rich Siegel)
Organization: Symantec/THINK Technologies, Bedford, MA
Lines: 39

In article <2583@munnari.oz> iand@munnari.oz (Ian Robert Dobson) writes:

>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.

	So, you want something for nothing? :-) It's not legal to cast a struct
to an integral type, or vice versa, but there are two ways to do it: the code
generated is identical, so it's strictly personal preference as to which you 
choose:

	Cell myCell;
	long myLong;

	1. 	myCell = *(Cell *)&myLong
	 2.	asm {move.l myLong, myCell}


	Solution (2) compiles in all cases, and solution 1 will only work
if "myLong" isn't a register variable. (You can't take the address of a
register variable.)

	--Rich




Rich Siegel
Staff Software Developer
THINK Technologies Division, Symantec Corp.
Internet: siegel@endor.harvard.edu
UUCP: ..harvard!endor!siegel
Phone: (617) 275-4800 x305

Any opinions stated in this article do not necessarily reflect the views
or policies of Symantec Corporation or its employees.