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,d71460587da14d5b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-31 09:59:34 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Importing C structs? Date: 31 Jul 2003 09:59:33 -0700 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0307310859.67460c46@posting.google.com> References: <1V1Wa.299$jp.55@newsread4.news.pas.earthlink.net> NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1059670774 29427 127.0.0.1 (31 Jul 2003 16:59:34 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 31 Jul 2003 16:59:34 GMT Xref: archiver1.google.com comp.lang.ada:41087 Date: 2003-07-31T16:59:34+00:00 List-Id: Ching Bon Lam wrote in message news:... > "Matthew Heaney" wrote in > news:1V1Wa.299$jp.55@newsread4.news.pas.earthlink.net: > > > This is probably overkill. For an opaque type all you need to do is: > > > > type DB_Type is limited null record; > > type DB_Access is access all DB_Type; > > for DB_Access'Storage_Size use 0; > > pragma Convention (C, DB_Access); > > overkill? i don't think so.. opaque_structure_def is defined in > Interfaces.C.Extensions (i-cexten.ads in gnat) as: > > subtype opaque_structure_def is System.Address; > > just a memory address. That's the same as DB *. Since the api (well, most > api written in C) only use DB * and not DB, you don't need another access > type. that's why A memory address is not the same thing as DB*. A "memory address" has type void*. A void* can point to anything. A DB* can not. You are free of course to use System.Address everywhere in Ada, just as you are free to use void* everywhere in C, but you lose strong typing that way. There is a reason why the C API used type DB* and not type void*. So I stand by my assertion that type opaque_structure_def is not the correct choice for a binding to dbopen().