I'm really not in favor of typedefs of the form XxxPtr,
they just serve to obscure something that really should
not be obscured. I -like- to see that little '*'.
Oh, another problem ... if WindowPtr is a #define like
#define WindowPtr Window *
then
WindowPtr pw1, pw2, pw3;
will result pw1 being an actual pointer to a Window,
but pw2 and pw3 will be Windows.
I hope WindowPtr is at least a typedef. (I say this
because I just searched for it, and found a couple of
prototypes using it, but did not find the definition
of it!)
--
-Richard M. Hartman
[EMAIL PROTECTED]
186,000 mi./sec ... not just a good idea, it's the LAW!
> -----Original Message-----
> From: Bob Ebert [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 01, 1999 7:40 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: OS header files; const in prototypes, especially in
> typedef'd pointers
>
>
> At 6:49 PM -0800 4/1/99, Alex Robinson wrote:
> >GCC doesn't like "const RectanglePtr" (or the equivalent,
> "RecanglePtr
> >const") to be used in parameters that actually are given real, const
> >data.
>
> Right, that's because "const RectanglePtr" is actualy the same as
> "RectangleType * const" -- that is, the pointer is being
> declared constant,
> NOT the thing it points to.
>
> I started to create typedefs like ConstRectanglePtr that expand to
> "RectangleType const *" or "const RectangleType *" (they are
> equivalent),
> but I'm starting to think this is a huge waste of time, and
> what we should
> actally be doing is getting rid of RectanglePtr entirely and
> explicitly
> using "const RectangleType *" in the headers.
>
> The only problem with _that_ is many of our types are intended to be
> opaque. That is, you should not know the structure of a
> WindowType, and we
> can't make the Win... routines take a "WindowType *" paramater without
> exposing WindowType.
>
> We _could_ make the Win... routines take a "void *" or "const void *"
> paramater, but then you lose a lot of type checking and will
> probably have
> to do funny casts. ...I suppose we could typedef WindowType
> to void for
> this...
>
> But anyway, that puts us back to having a public "WindowPtr"
> type that's
> passed around as a cookie outside of the OS, and _that_ means
> we have to
> create a "ConstWindowPtr" type for the cases where it's
> constant. <sigh>
>
> --Bob
>
>
>