私有类型声明抛出错误?我的代码如下,请帮我修复它 错误是=> “缺少私人类型t的完整声明”
spec文件
package rec is
type t is private;
give_public_acess:Constant t;
private
type int_array is array(1..5)of integer;
type t_type is record
max:integer:=0;
data:int_array;
end record;
give_public_acess:constant t_type:=(0,(others=>1)); --error is here adacore site says these is good but throwing error?
end rec;
答案 0 :(得分:1)
编译代码时,我收到 2 错误消息:
rec.ads:2:07: missing full declaration for private type "t"
rec.ads:10:03: type does not match declaration at line 3
这些都是因为您在公共部分中调用了t
类型,在私有部分中调用了t_type
。第一个意味着它的内容;第二个是因为在公共场合你说
give_public_acess:Constant t;
并在私人部分
give_public_acess:constant t_type
我建议您尝试使用-gnatl
进行编译(完整列表):这会在代码中散布错误消息,以便您获得
1. package rec is
2. type t is private;
|
>>> missing full declaration for private type "t"
3. give_public_acess:Constant t;
4. private
5. type int_array is array(1..5)of integer;
6. type t_type is record
7. max:integer:=0;
8. data:int_array;
9. end record;
10. give_public_acess:constant t_type:=(0,(others=>1)); --error is here adacore site says these is good but throwing error?
|
>>> type does not match declaration at line 3
11. end rec;