2015-01-04 112 views
-1

私有类型声明抛出的错误?我的代码如下,请帮我解决它 误差=>“丢失的私有类型吨全申报”私有类型声明抛出错误?

规范文件

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; 

回答

1

当我编译代码我得到错误信息:

rec.ads:2:07: missing full declaration for private type "t" 
rec.ads:10:03: type does not match declaration at line 3 

这些都是因为你调用的公共部分和类型在私人部分。第一种意思正是它所说的;二是因为在公共部分你说

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;