Complete beginner to Ada here. I am trying to compile and run a simple Ada program, from here: http://www.dwheeler.com/lovelace/s1sf.htm
Here is the code:
-- Demonstrate a trivial procedure, with another nested inside.
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;
procedure Compute is
procedure Double(Item : in out Integer) is
begin -- procedure Double.
Item := Item * 2;
end Double;
X : Integer := 1; -- Local variable X of type Integer.
begin -- procedure Compute
loop
Put(X);
New_Line;
Double(X);
end loop;
end Compute;
I'm on Linux, using gnat so I do:
gnatmake -c compute.adb
gnatmake compute
Which gives me the executable. Running the executable gives a list of zeros, as it seems to initialize X to 0, even though it says to initialize it to 1, so I should get a list 1,2,4,...
Can anyone explain either where my code or my thinking is wrong? Oh and using gnat is there a way to compile and create the executable in a single command?