我在以下情况下遇到约束错误:
从过程中获取受约束的缓冲区:
Get_MyBuffer(data => Buffer); -- This is ok
缓冲区的类型为 Unsigned_Byte。想将其转换为字节。
function To_Byte is new Unchecked_Conversion (Source => Unsigned_Byte,
Target => Byte);
MyFunction2Pass(To_Byte(Buffer)); -- Having warning 'uncheked conversion to unconstrained array subtype is not portable.
在 MyFunction2Pass 中打印
function MyFunction2Pass(Data : Byte) is
begin
New_Line(integer'image(integer(Data(1)))); -- **Shoot Constrain Error**
end