【发布时间】:2013-03-05 08:51:47
【问题描述】:
这里是 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 初始化为 0,即使它说要将其初始化为 1,所以我应该得到一个列表 1,2,4,...
谁能解释我的代码或我的想法哪里有问题?哦,使用 gnat 有没有办法在单个命令中编译和创建可执行文件?
【问题讨论】:
标签: compilation ada gnat