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 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ba2d61811afdbb11 X-Google-Attributes: gid103376,public From: Pascal Ledru Subject: Re: C->Ada: Converting char* to unsigned long Date: 1996/05/16 Message-ID: <319B8E99.1910@MSMAIL3.HAC.COM>#1/1 X-Deja-AN: 155194724 references: <319B3021.41C67EA6@is2.nyu.edu> content-type: text/plain; charset=us-ascii organization: Hughes Aircraft Company mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.01 (Macintosh; I; PPC) Date: 1996-05-16T00:00:00+00:00 List-Id: As you noticed the problem comes from the fact that you cannot instantiate Unchecked_Conversion (or any generic) with an unconstrained type. There is probably a simpler solution but the following will work: with Text_IO; with Interfaces.C.Strings; use Interfaces.C.Strings; procedure convert is package Integer_IO is new Text_IO.Integer_IO(Integer); C : chars_ptr; I : Integer; subtype Short_String is String(1..4); S : String(1..4); function To_Integer is new Unchecked_Conversion ( Source => Short_String, Target => Integer ); begin C := New_String( Str => "AAAA" & ASCII.NUL ); -- char* S := Value( Item => C); Integer_IO.Put( Item => To_Integer(S), Base => 16 ); Text_IO.New_Line; end;