1
我的代码如下。编译器不会让我使用判别式var
来控制字符串name
的大小。不能在记录中使用记录的判别式
procedure p is
type int is range 1 .. 10;
type my (var : int) is record
name : string (1 .. var); -- this var here is bad, why?
end record;
hh : my(6);
begin
put (hh.name);
end p;
的错误消息是
p.adb:4:23: expected type "Standard.Integer"
p.adb:4:23: found type "int" defined at line 2
为什么不使用'Ada.Strings.Bounded'? – trashgod 2014-12-03 12:40:14
如果您使用的是Gnat,错误消息会告诉您到底发生了什么问题。如果你使'int'成为'Integer'的子类型而不是新类型,你可以发现其他错误。 – 2014-12-03 12:40:16