From: ssh9614@hotmail.com (Bj?rn)
Subject: Pointer address
Date: 30 Dec 2004 03:29:10 -0800
Date: 2004-12-30T03:29:10-08:00 [thread overview]
Message-ID: <d56673df.0412300329.685a0f65@posting.google.com> (raw)
I'm trying to convert some C code into Ada.
I'm stuck on the follwing:
cpdata.dwData = 0x0001B001 (dwData being a ptr to an ulong)
Trying to execute the code below gives me a:
EXCEPTION_ACCESS_VIOLATION
If I change the address to 16#0001B000# the program just silently
exits/terminates without printing my put_line.
If I try to set DwData with an unchecked_conversion instead, using
address 16#0001B001#, the Address_Image returns 16#0001B000#.
I'm quite sure I'm doing something wrong here and need to read up a
bit on it. Could someone please give me some pointers here and maybe
the applicable parts of the ARM.
When I compile this on win-gnat-3.15 I get the following warnings:
temp.adb:17:08: warning: default initialization of "DwData" may modify
overlaid storage
temp.adb:17:08: warning: use pragma Import for "DwData" to suppress
initialization (RM B.1(24))
Adding an import pragma didn't seem to help more than removing the
warnings.
Thanks
Bj�rn
with Interfaces.C;
with Unchecked_Conversion;
with System.Storage_Elements;
with System.Address_Image;
with Text_IO;
procedure Temp is
type PULONG is access all Interfaces.C.Unsigned_Long;
function PULONG_To_Address is new Unchecked_Conversion
(PULONG, System.Address);
Some_Address : constant System.Address :=
System.Storage_Elements.To_Address(16#0001B000#);
DwData : PULONG;
for DwData'Address use Some_Address;
-- pragma Import (C, DwData);
begin
Text_IO.Put_Line ("dwData address = " & System.Address_Image
(PULONG_To_Address (DwData)));
end;
next reply other threads:[~2004-12-30 11:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-30 11:29 Bj?rn [this message]
2004-12-30 12:18 ` Pointer address Martin Krischik
2004-12-30 12:23 ` Vinzent 'Gadget' Hoefler
2004-12-30 18:51 ` tmoran
2004-12-31 9:57 ` Vinzent 'Gadget' Hoefler
2004-12-31 9:49 ` Björn
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox