我是一名 C 程序员,正在尝试实现我之前在 C 中实现的数据结构,但在 Ada 中实现。在我的头撞墙几次后,我决定向堆栈神寻求帮助。
procedure Ok is
type Node;
type Node is record
Next : access Node;
Prev : access Node;
end record;
begin
declare
a : aliased Node;
begin
a.Prev := a'Access;
end;
end;
Run Code Online (Sandbox Code Playgroud)
编译失败的原因是:
ok.adb:14:19: non-local pointer cannot point to local object这对我来说没有意义。哪个指针是非本地的?(如果在过程范围中定义了 a,则它有效)。
然后
procedure Ok is
type Node;
type Node is record
Next : access Node;
Prev : access Node;
end record;
procedure func(NodeOne : aliased in out Node) is
NodeP : access …Run Code Online (Sandbox Code Playgroud) ada ×1