Reputation: 1041
I want to create a task type (for example the a task type called "computer") with some task entries in Ada. I want to create a task entry with an input parameter of type "is access all computer", i.e. a pointer to the task type. Is this at all possible?
I tried to do something like this:
task type computer;
type computer_ptr is access all computer;
task type computer is
entry init(a: computer_ptr);
end computer;
This was suggested here. Unfortunately, this doesn't work: GNAT says that the declarations of "computer" conflict.
Can anyone think of a way to achieve what I want to do?
Upvotes: 4
Views: 1135
Reputation: 1804
By using task type computer;
, you declare a task type computer with no entries at all. Afterwards you declare another task type with the same name.
If you want to "forward-declare" the task type (as needed for the access type), you should just write type computer;
like for any other type. This is a incomplete type and can be completed by a task type declaration.
So your example should look like this:
type computer;
type computer_ptr is access all computer;
task type computer is
entry init (a: computer_ptr);
end computer;
Upvotes: 5