我在Ada中创建了记录,后来又从这些记录中创建了Synchronous_Fifo:
type Basic_Record is record
Argument_1: Integer;
Operator: Character;
Argument_2: Integer;
Product: Integer;
end record;
package Tasks_Fifo is new Synchronous_Fifo(Basic_Record);
use Tasks_Fifo;
Buffer : Fifo;而且这个运行得很好。后来,我想在对象之外做同样的Synchronous_Fifo:
package Adding_Machine is
protected type Add_Machine is
entry Store_Record(Task_Record: Basic_Record);
entry Push_Button;
entry Get_Product(Product: out Integer);
private
My_Record : Basic_Record;
My_Product: Integer;
end Add_Machine;
end Adding_Machine;
use Adding_Machine;
package Object_Fifo is new Synchronous_Fifo(Add_Machine);
use Object_Fifo;
Buffer: Fifo;结果我得到了几个错误:
Multiple markers at this line
- Occurrence of package
- actual for non-limited "Element_Type" cannot be a limited type
- instantiation abandoned在队列中,我在这里创建Object_Fifo。
我应该如何创建这个Fifo?或者可能是Adding_Machine包出了问题
发布于 2015-05-17 03:33:12
下面显示的是package Synchronous_Fifo
generic
type Element_Type is private;
package Synchronous_Fifo is
protected type Fifo is
entry Push(Item : Element_Type);
entry Pop(Item : out Element_Type);
private
Value : Element_Type;
Is_New : Boolean := False;
end Fifo;
end Synchronous_Fifo;
package body Synchronous_Fifo is
----------
-- Fifo --
----------
protected body Fifo is
---------
-- Push --
---------
entry Push (Item : Element_Type) when not Is_New is
begin
Value := Item;
Is_New := True;
end Push;
---------
-- Pop --
---------
entry Pop (Item : out Element_Type) when Is_New is
begin
Item := Value;
Is_New := False;
end Pop;
end Fifo;
end Synchronous_Fifo;我创建了对Adding_Machine的访问,后来又通过这些访问创建了先进先出。
type Adding_Machine_Access is access Adding_Machine;
package Adding_Machines_Fifo is new Synchronous_Fifo(adding_Machine_Access);
use Tasks_Fifo;
Adding_Machines_Fifo : Fifo;应该能行得通。
https://stackoverflow.com/questions/30260297
复制相似问题