2015-01-04 110 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;