From: Pascal Ledru <Ledru#m#_Pascal@MSMAIL3.HAC.COM>
Subject: Re: C->Ada: Converting char* to unsigned long
Date: 1996/05/16
Date: 1996-05-16T00:00:00+00:00 [thread overview]
Message-ID: <319B8E99.1910@MSMAIL3.HAC.COM> (raw)
In-Reply-To: 319B3021.41C67EA6@is2.nyu.edu
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;
prev parent reply other threads:[~1996-05-16 0:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-05-16 0:00 C->Ada: Converting char* to unsigned long Chris Jones
1996-05-16 0:00 ` Pascal Ledru [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox