Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!utgpu!water!watmath!watcgl!kdmoen
From: kdmoen@watcgl.UUCP
Newsgroups: comp.sys.mac
Subject: rect.top vs: rect.topLeft in C
Message-ID: <2571@watcgl.waterloo.edu>
Date: Wed, 2-Dec-87 20:34:08 EST
Article-I.D.: watcgl.2571
Posted: Wed Dec  2 20:34:08 1987
Date-Received: Sat, 5-Dec-87 17:49:29 EST
References: <870053@hpcilzb.HP.COM> <3424@husc6.harvard.edu>
Reply-To: kdmoen@watcgl.waterloo.edu (Doug Moen)
Organization: U. of Waterloo, Ontario
Lines: 34

tedj@hpcilzb.HP.COM (Ted Johnson) writes:
>Can someone tell me what I'm doing wrong here?  Using Lightspeed C v.2.11,
>I tried to do the following:
>
>		tempPoint = aRect.topLeft;

singer@endor.UUCP (Richard Siegal@THINK Technologies) writes:
>	You're getting confused between C and Pascal. In C there's no easy
>way to get at the variants of a record. Therefore, there's a macro (declared in
>"QuickDraw.h") for "topLeft" and "botRight". Instead of "aRect.topLeft", say
>"topLeft(aRect)", and all will be well.

Although I haven't seen this exact trick used in any Mac C environment
so far, it *is* possible to define Rect so that you can use the
syntax described in Inside Macintosh for accessing its fields:

typedef struct {
	Point topLeft;
	Point botRight;
} Rect;

#define top	topLeft.v
#define left	topLeft.h
#define bottom	botRight.v
#define right	botRight.h

Note that LightSpeed C defines top,left,bottom and right as fields
and topLeft,botRight as macros, while the above implementation does
the reverse, *and* gives you a cleaner syntax.
-- 
Doug Moen
University of Waterloo Computer Graphics Lab
UUCP:     {ihnp4,watmath}!watcgl!kdmoen
INTERNET: kdmoen@cgl.waterloo.edu