GNAT 允许以下代码,因为它Random(Generator, First, Last)
是在运行时实现的,但它不是 Ada 2012 的一部分。我是否可以导致它产生编译错误,因为它不应该可用?
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;
procedure Main is
package Positive_Random is new Ada.Numerics.Discrete_Random
(Result_Subtype => Positive);
Generator : Positive_Random.Generator;
-- This should fail, since function isn't part of Ada 2012.
Value : Positive := Positive_Random.Random (Generator, 1, 10);
begin
Put_Line (Value'Image);
end Main;
这是我的 gpr 文件:
project Default is
for Source_Dirs use ("src");
for Object_Dir use "obj";
for Main use ("main.adb");
package Compiler is
for Switches ("ada") use ("-gnat12");
end Compiler;
end Default;