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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,594935f0c2f19bc4 X-Google-Attributes: gid103376,public From: Alan Brain Subject: Re: how to pass access string across pragma C interface? Date: 1997/06/25 Message-ID: <33B1E458.49F0@dynamite.com.au>#1/1 X-Deja-AN: 252439765 References: <866734587.8496@dejanews.com> <01bc7f0c$494ab860$428371a5@dhoossr.iquest.com> Organization: @Home Reply-To: aebrain@dynamite.com.au Newsgroups: comp.lang.ada Date: 1997-06-25T00:00:00+00:00 List-Id: Robert Dewar wrote: > It is reasonable to assume that pointers to constrained array types are > easily mapped to C pointers, but it is asking for trouble to pass > pointers to unconstrained types. That is because the bounds information > must be somehow present, and C cannot know anything about it. > > Thus code that passes such pointers to C, and even more code that receives > such pointers FROM C, is liable to be highly implementation dependent. Correct. What you must do is to have a look at the compiler documentation. For BOTH C and Ada compilers. For the C Compiler, this will often mean looking at the source code for it (bleah). All Ada compilers in my experience state somewhere what the compiler's native representation of each data structure looks like. It took me 3 days to find it in the DDCI manuals once, but they have improved markedly since then. For example, one implementation may look like: 2 bytes giving a tag for this data structure (uunconstrained array, short unconstrained array, huge unconstrained array etc) 2-bytes giving an entry into a hash table of memory locations for start and length OR 2 bytes for length and 4 bytes for start address if it's a small unconstrained array. Another implementation may be completely different: just a 4-bytes length, with the data starting immediately afterwards. As for C, C++... they vary as well. If you're incredibly fortunate, then the internal representations might be identical. But in this case, I'd still write a wrapper, and put this with the other machine-dependent stuff, as different versions of the compilers can change their representations without notice. -- aebrain@dynamite.com.au <> <> How doth the little Crocodile | Alan & Carmel Brain| xxxxx Improve his shining tail? | Canberra Australia | xxxxxHxHxxxxxx _MMMMMMMMM_MMMMMMMMM 100026.2014 compuserve o OO*O^^^^O*OO o oo oo oo oo By pulling MAERKLIN Wagons, in 1/220 Scale See http://www.z-world.com/graphics/z/master/8856.gif for picture