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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,27e95161b8834d15 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: Character/Integer Conversion Date: 2000/04/03 Message-ID: <8cajeh$css$1@nnrp1.deja.com>#1/1 X-Deja-AN: 606129020 References: <8c3a6e$q5p$1@nnrp1.deja.com> <8ca7k8$v2q$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x37.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Mon Apr 03 17:13:04 2000 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; I) Date: 2000-04-03T00:00:00+00:00 List-Id: In article <8ca7k8$v2q$1@nnrp1.deja.com>, David C. Hoos, Sr. wrote: > I do this all the time, in the following way: > Msg : String (1 .. Length); > type Msg_Bytes is array (Msg'Range)of > Interfaces.C.Unsigned_Char; > use type Interfaces.C.Unsigned_Char; > Msg_Overlay : Msg_Bytes; > for Msg_Overlay'Address use Msg'Address; That's a particularly nasty low level hacking solution. It is inherently non-portable (the whole idea of the existence of the C.Unsigned_Char type is that it might have a different representation from Standard.Character), and it is a mistake to use low level address overlay stuff when there is a perfectly good solution. Note also that the effect of address overlays itself is implementation dependent, there is no requirement on a compiler that this "work" right, since "working" is not defined in the RM. In practice it probably wil work, though I would always make such variables aliased if you absolutely have to use address overlays. In addition, it is usually better to use Unchecked_Conversion than address overlays, since it is better defined, and the use is flagged in the context clause. Address overlays are definitely overused. Perhaps it was a mistake in Ada 95 to legitimize these (in Ada 83 they are erroneous, in Ada 95 implementation dependent). Anyway, the advice in the other message (using the 'Pos attribute) is a far better approach to your problem. One more trouble with the above declarations is that there is no guarantee that the address of an array is necessarily the address of the first element. The above declarations may simply result in overlaying dope vectors with peculiar results! Sent via Deja.com http://www.deja.com/ Before you buy.