建設

2011-11-08 7 views
2

私のように定義された型Primary_Taskからプライマリと呼ばれる親にリンクされたタスクのプロパティを持つエイダ2005年のクラスTest_Class、持っている:私は造る必要建設

type Test_Class is tagged limited 
     record 
     Info : Integer; 
     Value : Float; 
     Primary : Primary_Task (Test_Class'Access); 
     end record; 

をフォームでの私のクラスのためのワンステップコンストラクタ

function Construct (T : access Test_Class) return Test_Class_Ptr is 
    begin 
     return new Test_Class'(Info => T.Info + 1, 
          Value => 0.0, 
          Primary => [WHAT I WANNA KNOW]); 
    end Construct; 

現在、私のコードは次のとおりです。

-- test_pkg.ads 
package Test_Pkg is 
    type Test_Class; 
    type Test_Class_Ptr is access all Test_Class; 

    task type Primary_Task (This_Test : access Test_Class) is 
     pragma Storage_Size (1000); 
    end Primary_Task; 

    type Test_Class is tagged limited 
     record 
     Info : Integer; 
     Value : Float; 
     Primary : Primary_Task (Test_Class'Access); 
     end record; 

    function Construct (T : access Test_Class) return Test_Class_Ptr; 
end Test_Pkg; 

-- test_pkg.adb 
with Text_IO; use Text_IO; 
package body Test_Pkg is 
    [...] 

    function Construct (T : access Test_Class) return Test_Class_Ptr is 
     T_Ptr : constant Test_Class_Ptr := new Test_Class; 
    begin 
     T_Ptr.Info := T.Info + 1; 
     T_Ptr.Value := 0.0; 
     return T_Ptr; 
    end Construct; 
end Test_Pkg; 

どうすればコード化できますか? Primary => [...]コードにはどうすればよいですか? Test_Class定義のPrimary : Primary_Task (Test_Class'Access);の定義を変更する必要がありますか?

+0

あなたは達成しようとしていることに関するさらに詳しい情報を提供できますか?あなたはこれを読んだことがありますか:http://en.wikibooks.org/wiki/Ada_Programming/Tasking – NWS

+0

私はcomp.lang.adaで答えを待つべきではないかと思います(もちろん、その逆もあります)!ランディブルカートの答えは良かった。 –

+0

@SimonWright、Randyが正しいと思います。質問をする前に私はこの同じ解決策を使用しようとしました(これはあなたがcomp.lang.adaで前に私にいくつかの投稿を与えたようなものです)。しかし、問題は幸いにもコードではありませんでした。今、私はこの問題がGPL 2011バージョンのGNAT BUGかもしれないことに気付きました。自宅で私はGPLコンパイラを使っているだけなので、以前は成功することはできませんでした。しかし、おそらくgnatproはそれをクリアし、テストするつもりです。ありがとうございました。 – Rego

答えて

1

私はcomp.lang.adaのランディBrukardt(ありがとう)から答えました: 集計でコンポーネントを初期化するデフォルトに「<>」を使用し、エイダ2005以降では

を(どのあなたが仕事でできることは唯一のものです)。

(...)

function Construct (T : access Test_Class) return Test_Class_Ptr is 
begin 
return new Test_Class'(Info => T.Info + 1, 
         Value => 0.0, 
         Primary => <>); 
end Construct; 

はしかし、私はGNAT GPL 2011を使用して、それをコンパイルしようとしたので、GNAT GPLのユーザーはを待つ必要があり

c:\tst>gnatmake -gnat12 test_pkg.adb 
gcc -c -gnat12 test_pkg.adb 

+===========================GNAT BUG DETECTED==============================+ 
| GPL 2011 (20110428) (i686-pc-mingw32) GCC error:       | 
| in create_tmp_var, at gimplify.c:505          | 
| Error detected around test_pkg.adb:20:29       | 
| Please submit a bug report by email to [email protected]    | 
| GAP members can alternatively use GNAT Tracker:       | 
| http://www.adacore.com/ section 'send a report'.       | 
| See gnatinfo.txt for full info on procedure for submitting bugs.   | 
| Use a subject line meaningful to you and us to track the bug.   | 
| Include the entire contents of this bug box in the report.    | 
| Include the exact gcc or gnatmake command that you entered.    | 
| Also include sources listed below in gnatchop format      | 
| (concatenated together with no headers between files).     | 
| Use plain ASCII or MIME attachment.          | 
+==========================================================================+ 
Please include these source files with error report 
Note that list may not be accurate in some cases, 
so please double check that the problem can still 
be reproduced with the set of files listed. 
Consider also -gnatd.n switch (see debug.adb). 

test_pkg.adb 
test_pkg.ads 

raised TYPES.UNRECOVERABLE_ERROR : comperr.adb:423 
gnatmake: "test_pkg.adb" compilation error 

の下GNATBUGを得ましたこのソリューションを使用する次のリリース