🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1408

Re: pointer to incomplete type?

#1408
From: diamond
Date: Thu, 07 Jun 1990 00:54
33 lines
2043 bytes
In article <7565@ncar.ucar.edu> steve@groucho.ucar.edu (Steve Emmerson) writes:
>In <13048@smoke.BRL.MIL> gwyn@smoke.BRL.MIL (Doug Gwyn) writes:
>>In article <1680@mcrware.UUCP> jejones@mcrware.UUCP (James Jones) writes:
>>>how can one safely declare a pointer to an incomplete structure, union, or
>>>enumerated type?
>>The type must be complete before any use that depends on it.

Doug Gwyn didn't exactly answer James Jones' question.  Thus Steve
Emmerson's confusion:

>	In file foo.h:
>		typedef struct FooTag	*FooPtr;
>		extern FooPtr		FooCreate();
>		extern void		FooFree(FooPtr foo);

This will work, because clients use only pointers.  A pointer type
is complete, even if the pointed-to type is not complete yet.
If clients try to use *FooCreate() or FooCreate()->someMember,
or if there is a declaration FooOp(struct FooTag someFoo),
then clients will get in trouble because the struct type is incomplete.

>The rationale for this is that clients using the "foo" ADT include
>"foo.h" and pass variables of type "FooPtr" around but are otherwise
>prevented from knowing any details of its implementation (no style 
>flames please).

This is a perfectly reasonable thing to do.  Now, what kind of goof are
you, resorting to begging "no style flames please" instead of using clear
arguments to properly justify this approach?  ( :-) Teasing only.)

-- 
Norman Diamond, Nihon DEC     diamond@tkou02.enet.dec.com
Proposed group comp.networks.load-reduction:  send your "yes" vote to /dev/null.
Technical Details
Message-ID: <1773@tkou02.enet.dec.com>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!shlump.nac.dec.com!tkou02.enet.dec.com!diamond
References: <13048@smoke.BRL.MIL> <7565@ncar.ucar.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!shlump.nac.dec.com!tkou02.enet.dec.com!diamond
From: diamond@tkou02.enet.dec.com (diamond@tkovoa)
Newsgroups: comp.std.c
Subject: Re: pointer to incomplete type?
Message-ID: <1773@tkou02.enet.dec.com>
Date: 7 Jun 90 00:54:42 GMT
References: <13048@smoke.BRL.MIL> <7565@ncar.ucar.edu>
Reply-To: diamond@tkou02.enet.dec.com (diamond@tkovoa)
Organization: Digital Equipment Corporation Japan , Tokyo
Lines: 33