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: <8cajks$d71$1@nnrp1.deja.com>#1/1 X-Deja-AN: 606131773 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:16:29 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; One more point about the above dubious code. There is no guarantee that the declaration of Msg_Overlay will not clobber the valeu in Msg. This probably will not affect anything, but in other cases it can. It is probably a good idea to always use a pragma Import (Ada, ..) for the variable doing the overlaying to inhibit any default initialization associated with the variable. For example, in x : integer := f (x); y : access_to_integer; for y'address use x'address; the declaration of y will likely clobber the initial value of x, and we should prevent that by either writing: x : integer := f (x); y : access_to_integer; for y'address use x'address; pragma Import (Ada, y); or better by not using address overlays (an unchecked conversion would be far safer and clearer in this situation). Sent via Deja.com http://www.deja.com/ Before you buy.