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 10:47:26 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!snoopy.risq.qc.ca!nf3.bellglobal.com!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail From: "Warren W. Gay VE3WWG" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Importing C structs? References: <1V1Wa.299$jp.55@newsread4.news.pas.earthlink.net> <1ec946d1.0307310859.67460c46@posting.google.com> In-Reply-To: <1ec946d1.0307310859.67460c46@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Thu, 31 Jul 2003 13:32:22 -0400 NNTP-Posting-Host: 198.96.223.163 X-Complaints-To: abuse@sympatico.ca X-Trace: news20.bellglobal.com 1059672737 198.96.223.163 (Thu, 31 Jul 2003 13:32:17 EDT) NNTP-Posting-Date: Thu, 31 Jul 2003 13:32:17 EDT Organization: Bell Sympatico Xref: archiver1.google.com comp.lang.ada:41096 Date: 2003-07-31T13:32:22-04:00 List-Id: Matthew Heaney wrote: > 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(). From what I have seen in this thread, this "project" should be a "binding" so that these types of entities are not directly used by a client program. In this way, you can carry DB* arround any way that makes sense, as long as it is properly preserved internally (perhaps in an Ada tagged record), and nulled when it is invalid to reference it. Sometimes within a binding, an external entity's precise makeup cannot be [conveniently/portably] known. But if you only need to reference it, then this is no hardship. You then only have to properly manage its use. -- Warren W. Gay VE3WWG http://home.cogeco.ca/~ve3wwg