Ada の完全な初心者はこちら。ここから簡単な Ada プログラムをコンパイルして実行しようとしています: http://www.dwheeler.com/lovelace/s1sf.htm
コードは次のとおりです。
-- 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;
私は Linux を使用しており、gnat を使用しています。
gnatmake -c compute.adb
gnatmake compute
これにより、実行可能ファイルが得られます。実行可能ファイルを実行すると、X を 1 に初期化するように指示されているにもかかわらず、X を 0 に初期化するように見えるため、ゼロのリストが表示されるため、リスト 1,2,4,... を取得する必要があります。
私のコードまたは私の考えが間違っている場所を誰かが説明できますか? ああ、gnat を使用して、単一のコマンドで実行可能ファイルをコンパイルして作成する方法はありますか?