私有类型声明抛出错误?
private type declaration is throwing error?
私有类型声明抛出错误?我的代码在下面请帮我修复它
错误是=> "missing full declaration of private type t"
规格文件
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;
当我编译你的代码时,我收到 2 错误消息:
rec.ads:2:07: missing full declaration for private type "t"
rec.ads:10:03: type does not match declaration at line 3
这都是因为你在public部分调用了类型t
,在私有部分调用了t_type
。第一个意思就是它所说的;第二个是因为在 public 部分你说
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;
私有类型声明抛出错误?我的代码在下面请帮我修复它 错误是=> "missing full declaration of private type t"
规格文件
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;
当我编译你的代码时,我收到 2 错误消息:
rec.ads:2:07: missing full declaration for private type "t"
rec.ads:10:03: type does not match declaration at line 3
这都是因为你在public部分调用了类型t
,在私有部分调用了t_type
。第一个意思就是它所说的;第二个是因为在 public 部分你说
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;