【发布时间】:2019-08-07 05:08:50
【问题描述】:
我正在尝试使用 gcc -c Calculator.ada 编译此 Calculator.ada 文件并收到错误 warning: Calculator.ada: linker input file unused because linking not done - 我已尝试查找解决方案并下载其他可能为我编译但尚未想到的东西还没出来……
这里是Calculator.ada:
--
-- Integer calculator program. Takes lines of input consisting of
-- <operator> <number>, and applies each one to a display value. The
-- display value is printed at each step. The operator is one of =,
-- +, -, *, /, or ^, which correspond to assign, add, subtract, multiply
-- divide, and raise, respectively. The display value is initially zero.
-- The program terminates on a input of q.
--
with Text_IO;
with Gnat.Io; use Gnat.Io;
procedure Calc is
Op: Character; -- Operation to perform.
Disp: Integer := 0; -- Contents of the display.
In_Val: Integer; -- Input value used to update the display.
begin
loop
-- Print the display.
Put(Disp);
New_Line;
-- Promt the user.
Put("> ");
-- Skip leading blanks and read the operation.
loop
Get(Op);
exit when Op /= ' ';
end loop;
-- Stop when we're s'posed to.
exit when Op = 'Q' or Op = 'q';
-- Read the integer value (skips leading blanks) and discard the
-- remainder of the line.
Get(In_Val);
Text_IO.Skip_Line;
-- Apply the correct operation.
case Op is
when '=' => Disp := In_Val;
when '+' => Disp := Disp + In_Val;
when '-' => Disp := Disp - In_Val;
when '*' => Disp := Disp * In_Val;
when '/' => Disp := Disp / In_Val;
when '^' => Disp := Disp ** In_Val;
when '0'..'9' => Put_Line("Please specify an operation.");
when others => Put_Line("What is " & Op & "?");
end case;
end loop;
end Calc;
对于我为什么无法编译它的任何帮助,我将不胜感激。我可以使用 gcc -c 编译 C 文件,并且读到我可以为 Ada 编译相同的方式。
【问题讨论】:
-
它没有编译,或者我错过了什么@EugeneSh。 ?我只拥有 .ada,不应该在那里/产生了 .o 吗?
-
给定this,ADA程序应该有一个扩展名
adb或ads。可能是gcc只是不明白这是一个 ADA 程序... -
Type "gnat --version" ... 如果你得到 "command not found" 你的 gcc 安装不完整,你必须找到并安装它的 Ada 部分(通常是一个名为“gnat-
。然后“gnatmake Calculator.adb”(重命名文件!)应该编译并链接它(及其所有依赖项)