Reputation: 5098
What is the problem with this code? Compiler says two things, that there is no Run entry and that Run accept does not match an entry (both seem wrong), and separately that Train cannot be used before declaration (but it is already declared). Please explain to me what is going on.
I am hesitant to show entire code but can do so.
type ItineraryType is array (0..255) of Integer;
type Train is record
Label : Integer;
Capacity : Integer;
Maxspeed : Integer;
Starts : Integer;
Itinerary : ItineraryType;
Stops : Integer;
lock : access Mutex;
end record;
task type TrainThread is
entry Run (train1:Train);
end;
task body TrainThread is
train : Train;
begin
accept Run (train1:Train) do
train := train1;
end;
end;
-- part of main
train1 := new TrainThread;
train1.Run(trains(i));
main.adb:51:05: warning: no accept for entry "Run"
main.adb:52:17: object "Train" cannot be used before end of its declaration
main.adb:54:09: no entry declaration matches accept statement
gnatmake: "main.adb" compilation error
Upvotes: 3
Views: 2203
Reputation: 2785
Ada is case insensitive, so train
and Train
are equivalent. So the declaration train : Train
will always be invalid. (Admittedly gnat's message could be better in this case)
Upvotes: 6