我无论如何都无法在GPS中编译(不运行)我的Ada代码.我收到一个错误:
cannot generate code for file random.ads (package spec)
gprbuild: *** compilation phase failed
Run Code Online (Sandbox Code Playgroud)
random.ads文件如下所示:
with Ada.Numerics.Float_Random;
use Ada.Numerics.Float_Random;
package random is
protected randomOut is
procedure Inicializal;
entry Parcel(
randomout: out Positive;
from: in Positive;
to: in Positive := 1
);
private
G: Generator;
Inicializalt: Boolean := False;
end randomOut;
task print is
entry write(what: in String);
end print;
end random;
Run Code Online (Sandbox Code Playgroud)
.gpr文件如下所示:
project Default is
package Compiler is
for Default_Switches ("ada") use ("-g", "-O2");
end Compiler;
for Main use ("hunting.adb");
end Default;
Run Code Online (Sandbox Code Playgroud)
这是什么意思?我该如何解决?谢谢!
您无法为包规范生成代码.
这是正常的和预期的.
你可以编译包体,random.adb,并为它生成代码 - 但通常没有必要.
只需编译您的主程序(或者您的测试工具,如果您是单元测试)并让编译器找到它的所有依赖项.
(如果它不能,或者你还没有写它们,或者它正在寻找错误的地方.如果你需要帮助,请在问题中添加相关信息).