【问题标题】:private type declaration is throwing error?私有类型声明抛出错误?
【发布时间】:2015-01-04 10:39:42
【问题描述】:
私有类型声明抛出错误?我的代码在下面请帮我修复它
错误是=>“缺少私有类型 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;
【问题讨论】:
标签:
constants
private
record
ada
【解决方案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;