我试图编译这个Calculator.ada
文件使用gcc -c Calculator.ada
并收到错误warning: Calculator.ada: linker input file unused because linking not done
- 我试过寻找解决方案并下载其他东西,可能编译这个但我还没有想通出来呢....Ada - 用GCC编译Ada
这里是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。 ?我sitll只有.ada,不应该/已经产生了一个.o? – NikkiNelson
鉴于[this](https://gcc.gnu.org/onlinedocs/gnat_ugn/Running-a-Simple-Ada-Program.html),ADA计划应该有一个扩展名“adb”或“ads”。这可能是'gcc'只是不明白它是一个ADA程序... –
键入“gnat --version”...如果你得到“命令未找到”你的gcc安装不完整,你会有找到并安装它的Ada部分(通常是一个名为“gnat-”的包,然后“gnatmake Calculator.adb”(重命名该文件!)应编译并链接它(及其所有依赖项) –