From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4deb6c62a5e19f2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-29 19:09:30 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!howland.erols.net!news-out.worldnet.att.net.MISMATCH!wn3feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc04-news.ops.worldnet.att.net.POSTED!not-for-mail Message-ID: <3B64C26F.C195B4E0@worldnet.att.net> From: James Rogers X-Mailer: Mozilla 4.76 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: type Foo_ptr in new void*; References: <9k03jc$2me$2@news.tpi.pl> <9k0j60$n4t$1@news.tpi.pl> <3B63F48A.2E2642C6@earthlink.net> <9k2btj$5hj$1@news.tpi.pl> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 30 Jul 2001 02:09:29 GMT NNTP-Posting-Host: 12.86.35.22 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 996458969 12.86.35.22 (Mon, 30 Jul 2001 02:09:29 GMT) NNTP-Posting-Date: Mon, 30 Jul 2001 02:09:29 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:10707 Date: 2001-07-30T02:09:29+00:00 List-Id: Tomasz Wegrzanowski wrote: > > In article <3B63F48A.2E2642C6@earthlink.net>, Marc A. Criley wrote: > >> I can't do this. > >> Foo is supposed to be used only as a pointer. > >> I don't know if newer version of library will use the same Foo. > > > > In tmoran's post, wherever you saw "in out Foo", change it to "in > > Foo_Pointer". > > > > In order to declare a pointer to a type, you have to have that type's > > definition. Even C requires that for "foo*" there be some declaration > > of "foo". > > Not true. > You can use `struct Foo *' without declaring `struct Foo'. > You can `typedef struct Foo Foo_t;' or `typedef struct Foo *Foo_p;' > and use Foo_t and Foo_p w/o declaring `struct Foo'. Yes, you are correct. C does allow you to forward declare a structure or a pointer without ever completing the definition. This is one of the nasty capabilities "provided" by C. You can even create an array of Foo *. However, pointer arithmetic from the start of this array produces unspecified behavior. What is the sizeof Foo? Since it is undefined, there is no correct answer to that question. Without a proper definition of the sizeof Foo, there can be no reliable pointer arithmetic. In other words, you can declare some wonderful data structures in C based on incomplete type definitions. Unfortunately, a program built upon such a structure is neither reliable nor portable. Ada does not allow you to compile a program with an incomplete type definition. There is no equivalent because the existence of an equivalent to this C capability would only introduce errors in your program. There is nothing positive that can be achieved by allowing a program to be incompletely specified. I first realized the differences between C and Ada in this respect when first learning Ada to support the development of debuggers for in circuit emulators in 1994. I had to produce programs exhibiting every data type you can produce from each language so that the symbolic debug output of compilers, and recognition of the debuggers could be verified. There was never a version of Ada that supported incomplete type definition. Jim Rogers Colorado Springs, Colorado USA