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-28 22:56:04 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!newsfeed.direct.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: type Foo_ptr in new void*; References: <9k03jc$2me$2@news.tpi.pl> X-Newsreader: Tom's custom newsreader Message-ID: Date: Sun, 29 Jul 2001 05:56:03 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 996386163 24.7.82.199 (Sat, 28 Jul 2001 22:56:03 PDT) NNTP-Posting-Date: Sat, 28 Jul 2001 22:56:03 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:10680 Date: 2001-07-29T05:56:03+00:00 List-Id: > Foo *foo_new(some args); > void foo_delete(Foo*); > void foo_some_operation(Foo*,some args); > xyz foo_some_function(Foo*,some args); > > How should I typedef Foo* ? Presumably you "typedef Foo" in the C code in normal C style. If you are wondering how to describe these C functions in Ada, from the implementation advice in ARM B.3(67 .. 70), as given at www.adapower.com: 4.An Ada in parameter of an access-to-object type with designated type T is passed as a t* argument to a C function, where t is the C type corresponding to the Ada type T. 5.An Ada access T parameter, or an Ada out or in out parameter of an elementary type T, is passed as a t* argument to a C function, where t is the C type corresponding to the Ada type T. In the case of an elementary out or in out parameter, a pointer to a temporary copy is used to preserve by-copy semantics. 6.An Ada parameter of a record type T, of any mode, is passed as a t* argument to a C function, where t is the C struct corresponding to the Ada type T. 7.An Ada parameter of an array type with component type T, of any mode, is passed as a t* argument to a C function, where t is the C type corresponding to the Ada type T. So given type Foo is record ... type Foo_Pointer is access Foo; > Foo *foo_new(some args); function foo_new(someargs : sometype) return Foo_Pointer; > void foo_delete(Foo*); procedure foo_delete(Param : in out Foo); > void foo_some_operation(Foo*,some args); procedure foo_some_operation(Param : in out Foo; someargs : in sometype); > xyz foo_some_function(Foo*,some args); function foo_some_function(P : Foo_Pointer; someargs : sometype) return xyz; There are other ways, for instance procedure foo_delete(Param : access Foo);