我試圖編譯這個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」(重命名該文件!)應編譯並鏈接它(及其所有依賴項) –