我是 Ada 新手,所以我有一个问题:如何定义一个包含两个多维无约束数组的结构并将其传递给过程。 按照我写的代码:
package SDR_Treatment is
-----------------------------------------------------------------------------
-- CONSTANTS -
-----------------------------------------------------------------------------
GEO_SPACIAL_AND_SPEED: constant Natural := 1; --Type of Data
-----------------------------------------------------------------------------
type Slicing_Pointers is array (Positive range <>) of Integer;
type Region is array (Positive range <>, Positive range <>, Positive range <>) of Integer;
type Location_and_Speed_Region is record
Region_Id : Natural := 0;
SP: Slicing_Pointers;
Rig: Region;
end record;
procedure SDR_Encoding(lsr: in out Location_and_Speed_Region);
end SDR_Treatment;
-----------------------------------------------------------------------------
包体:
with Ada.Text_IO; use Ada.Text_IO;
package body SDR_Treatment is
procedure SDR_Encoding(lsr: in out Location_and_Speed_Rigion) is
-- lsr : rig;
begin
Ada.Text_IO.Put_Line("Encoding SDR...");
end SDR_Encoding;
end SDR_Treatment;
_____________________________________________________________________________
这是我从编译器得到的错误
C:\GNAT\2017\bin\src\sdr_treatment.ads
18:11 unconstrained subtype in component declaration
19:12 unconstrained subtype in component declaration
正如编译器所说,您不能声明具有不受约束的子类型的记录组件。
您必须修复约束作为记录声明的一部分:
package SDR_Treatment is
type Slicing_Pointers is array (Positive range <>) of Integer;
type Region is array (Positive range <>,
Positive range <>,
Positive range <>) of Integer;
type Location_and_Speed_Region (Low : Positive;
High : Natural;
X_Low : Positive;
X_High : Natural;
Y_Low : Positive;
Y_High : Natural;
Z_Low : Positive;
Z_High : Natural) is
record
Region_ID : Natural := 0;
SP : Slicing_Pointers (Low .. High);
Rig : Region (X_Low .. X_High,
Y_Low .. Y_High,
Z_Low .. Z_High);
end record;
end SDR_Treatment;