[comp.sys.mac.programmer] LLastClick assignment in C

francis@mirror.UUCP (Joe Francis) (01/03/90)

-----------------------------------------------------------------------

Using Think C 3.0 with the following code:

Cell	cell;

cell = LLastClick(...);

I get the message "illegal operation on struct/union".
I have circumvented with:

long	lcell;
Cell	cell;

lcell = (long)LLastClick(...);
cell.v = HiWord(lcell);
cell.h = LoWord(lcell);

But personally I find this solution aesthetically distasteful "in the
extremus", as Mr. Conrad would say.

I tried casting cell, but C doesn't seem to like casting lvalues.
Somebody please banish this distraction from my code.


-----------------------------------------------------------------------
SPAM! SPAM! SPAM! SPAM! SPAM! SPAM! SPAM! SPAM! SPAM! SPAM! SPAM! SPAM! 
Joe Francis
francis@prism.TMC.COM    .or.			Nobody Expects the
francis@mirror.TMC.COM				Spammish Repitition
-----------------------------------------------------------------------

oster@dewey.soe.berkeley.edu (David Phillip Oster) (01/03/90)

In article <34554@mirror.UUCP> francis@prism.TMC.COM (Joe Francis) writes:
>Cell	cell;
>
>cell = LLastClick(...);
>
>I get the message "illegal operation on struct/union".

This is a documented wart in THINK C, having to do with an interawction
for the non-C way that Mac calls return structs. Here is a work around
that generates zero extra code:

Cell	cel;

*((long *) &cell) = LLastClick(...);

--- David Phillip Oster            --  No, I come from Boston. I just work
Arpa: oster@dewey.soe.berkeley.edu --  in cyberspace.
Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu