a***@nihamkin.com
2018-02-23 08:54:26 UTC
I am cross costing a question from SO since it looks like all the Ada experts are here and not there :)
https://stackoverflow.com/questions/48939845/non-local-pointer-cannot-point-to-local-object
Can someone explain why I get "non-local pointer cannot point to local object" error, even though it looks like "Arr" and "Arr_Access" have the same accessibility level?
Can I overcome the problem without dynamically allocating memory and without using "Unchecked_Access"?
with Interfaces.C;
with Interfaces.C.Strings;
procedure X is
type Integer_Access is access all Integer;
Arr_Access : Interfaces.C.Strings.char_array_access;
Arr : aliased Interfaces.C.char_array := Interfaces.C.To_C ("From");
A : Integer_Access;
I : aliased Integer := 6;
begin
Arr_Access := Arr'Access;
A := I'Access;
end X;
Thank you,
Artium
https://stackoverflow.com/questions/48939845/non-local-pointer-cannot-point-to-local-object
Can someone explain why I get "non-local pointer cannot point to local object" error, even though it looks like "Arr" and "Arr_Access" have the same accessibility level?
Can I overcome the problem without dynamically allocating memory and without using "Unchecked_Access"?
with Interfaces.C;
with Interfaces.C.Strings;
procedure X is
type Integer_Access is access all Integer;
Arr_Access : Interfaces.C.Strings.char_array_access;
Arr : aliased Interfaces.C.char_array := Interfaces.C.To_C ("From");
A : Integer_Access;
I : aliased Integer := 6;
begin
Arr_Access := Arr'Access;
A := I'Access;
end X;
Thank you,
Artium