代码之家  ›  专栏  ›  技术社区  ›  Mate

“ADA.FLOAT_IO”不是预定义的库单元

ada
  •  2
  • Mate  · 技术社区  · 8 年前

    为什么会出现此错误?

    “ADA.FLOAT_IO”不是预定义的库单元

    我以前从未在ADA中写过任何东西,只是我不知道自己在做什么。我使用GNAT进行编译。

    with Ada.Text_IO; use Ada.Text_IO;
    with Ada.Float_IO; use Ada.Float_IO;
    with Ada.Numerics.Elementary_Functions;
    use Ada.Numerics.Elementary_Functions;
    
    procedure MAIN is
       A,B,C:Float;
       W : Float;
       Re, Im:Float;
    begin
       Put("Give A");Get(A);
       Put("Give B");Get(B);
       Put("Give C");Get(C);New_Line;
       if A=0.0 then
          Put_Line("It is not second degree polynomial");
       else
          W:=B*B - 4.0*A*C;
          Re:=B/(2.0*A); Im:=Sqrt(Abs(W))/(2.0*A);
          Put("dif = "); Put(W);New_Line;
          if W<0.0 then
             Put_Line("Complex ");
             Put("x1 = ");Put(-Re);Put(" -j ");Put(Im);Put(" ");
             Put("x2 = ");Put(-Re);Put(" +j ");Put(Im);New_Line;
          else
             Put_Line("Real");
             Put("x1 = ");Put(-Re-Im);Put(" ");
             Put("x2 = ");Put(-Re+Im);
          end if;
       end if;
    end MAIN;
    
    1 回复  |  直到 8 年前
        1
  •  6
  •   Álex    8 年前

    IIRC公司 Float_IO 是的孩子 Text_IO : Ada.Text_IO.Float_IO 此外,这是一个通用包。我想你想要 Ada.Float_Text_IO ,定义为

    package Ada.Float_Text_IO is new Ada.Text_IO.Float_IO (Float);