简而言之,为什么这不起作用:
generic
Max : in Positive;
package Modular_Gen_Issue is
procedure Foo;
private
type Mod_Thing is mod Max; -- NOK
type Int_Thing is new Integer range 0 .. Max; -- OK
end Modular_Gen_Issue;
通过编译:
$ gnatmake modular_gen_issue.ads
gcc-4.4 -c modular_gen_issue.ads
modular_gen_issue.ads:6:26: non-static expression used for modular type bound
modular_gen_issue.ads:6:26: "Max" is not static constant or named number (RM 4.9(5))
gnatmake: "modular_gen_issue.ads" compilation error
$
如何传入单个数字并使用它来定义模块化类型?
是的,它必须是模块化类型!