错误:无法为文件random.ads生成代码(程序包规格) [英] Error: cannot generate code for file random.ads (package spec)
本文介绍了错误:无法为文件random.ads生成代码(程序包规格)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我以某种方式无法在GPS中编译(不运行)我的Ada代码。我收到错误消息:
I somehow cannot compile (neither run) my Ada code in GPS. I get an error:
cannot generate code for file random.ads (package spec)
gprbuild: *** compilation phase failed
random.ads文件如下所示:
The random.ads file looks like this:
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;
.gpr文件如下所示:
The .gpr file looks as follows:
project Default is
package Compiler is
for Default_Switches ("ada") use ("-g", "-O2");
end Compiler;
for Main use ("hunting.adb");
end Default;
这是什么意思?我该如何解决?谢谢!
What does this mean? How can I fix it? Thank you!
推荐答案
问题是由
task print is
entry write(what: in String);
end print;
由于将任何任务指定为主体,因此编译器难以决定:它具有主体必须在不需要的规范文件中进行编译。将任务移至.adb文件即可解决此问题。
As any task is specified as a body, the compiler had trouble deciding: it had a body, that has to be compiled, in a spec file, which does not. Moving the task to the .adb file solved the issue.
这篇关于错误:无法为文件random.ads生成代码(程序包规格)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文