Reputation: 3248
It seems so simple but this does not compile:
procedure Main is
begin
exit 1;
end Main;
When compiled with gprbuild, yields:
Compile
[Ada] main.adb
main.adb:3:04: cannot exit from program unit or accept statement
main.adb:3:08: missing ";"
gprbuild: *** compilation phase failed
The exit keyword in Ada clearly doesn't do what it does in other programming languages. So how do you exit from the ada main procedure with an error code?
Upvotes: 2
Views: 796
Reputation: 6430
How about:
with Ada.Command_Line;
procedure Main is
begin
Ada.Command_Line.Set_Exit_Status(Ada.Command_Line.Failure);
end Main;
Upvotes: 5
Reputation: 3248
Make your Ada main program a function, not a procedure, and return the exit code you want:
function Main return integer is
begin
return 1;
end Main;
Upvotes: 0