小编Sim*_*ght的帖子

Ada中的编译器放弃了Generic类型的包实例化

好的,所以我尝试运行调用包dirforinv.adb的代码:

WITH  Text_IO;
WITH  Ada.Numerics.Generic_Real_Arrays;
WITH  Ada.Numerics.Generic_Elementary_functions;
WITH  Ada.Strings.Fixed;
WITH  dirforinv;
PROCEDURE  levfordir  IS

J : CONSTANT  Integer := 100;

TYPE  Real  IS DIGITS  13;

PACKAGE  Real_IO  IS NEW  Text_IO.Float_IO   (Real);
PACKAGE  Int_IO   IS NEW  Text_IO.Integer_IO (Integer);

TYPE  Gen_arr  IS ARRAY (INTEGER RANGE <>, INTEGER RANGE <>)  OF  Real;
TYPE  var_array  IS ARRAY (INTEGER RANGE <>)  OF  Real;

PACKAGE  Real_arrays  IS NEW Ada.numerics.Generic_Real_Arrays (Real);
USE      Real_arrays;
PACKAGE  sdirect      IS NEW dirforinv (var_array, Gen_arr);
PACKAGE  Math         IS NEW Ada.numerics.Generic_Elementary_functions (Real);
USE …
Run Code Online (Sandbox Code Playgroud)

ada instantiation

0
推荐指数
1
解决办法
556
查看次数

ada中的字符串操作

我正在获取字符串中的目录路径,例如"C:\Users\Me\Desktop\Hello”,我正在尝试获取最后一个目录,但没有成功.

我在字符串上尝试了很多操作但是在一天结束时我什么也没有留下......我将很感激能得到一些帮助.谢谢 !

这是我的第一个想法:

Get_Line(Line, Len);
while (Line /="") loop
   FirstWord:=Index(Line(1..Len),"\")+1;
   declare
      NewLine :String := (Line(FirstWord .. Len));
   begin
      Line:=NewLine ; 
   end;
end loop;
Run Code Online (Sandbox Code Playgroud)

我知道它不起作用(我不能分配NewLine,Line因为它们的长度之间没有匹配),现在我卡住了.

string ada

0
推荐指数
1
解决办法
511
查看次数

在过程中使用包规范

我想在一个过程中使用一个包规范.

有些东西不见了,但我不知道是什么.

using_ads_package.adb:14:11:"var"不可见

using_ads_package.adb:14:11:第8行的不可见声明

with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO.Unbounded_IO;  use Ada.Text_IO.Unbounded_IO;

Procedure using_ads_package is

   Package variable is

      var : Unbounded_String ;

   end variable ;

Begin

   get_line(var);

End using_ads_package ;
Run Code Online (Sandbox Code Playgroud)

ada

0
推荐指数
1
解决办法
168
查看次数

如何比较ada 95中的字符串

我刚刚开始学习Ada 95,我在比较字符串方面遇到了一些问题.

这是代码:

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; 
with Ada.Command_Line;
with Ada.Strings.Unbounded;

procedure Test1 is

   vad : String(1..9);
   Amount : Integer;
   Main : Integer;
   Second : Integer;
   Third : Integer;

begin
   Main := 1;
   Second := 0;
   Third := 0;

   Put("What do you want to do?");
   New_Line(1);
   Get(vad);
   New_Line(1);

   if Vad  = "fibonacci" then
      Put("How long do you want the sequence to be");
      New_Line(1);

      Get(Amount);
      New_Line(1);

      Amount := Amount -1;

      for I in 1 .. Amount loop …
Run Code Online (Sandbox Code Playgroud)

string if-statement compare ada

0
推荐指数
1
解决办法
1012
查看次数

错误:无法生成文件random.ads的代码(包规范)

我无论如何都无法在GPS中编译(不运行)我的Ada代码.我收到一个错误:

cannot generate code for file random.ads (package spec)
gprbuild: *** compilation phase failed
Run Code Online (Sandbox Code Playgroud)

random.ads文件如下所示:

with Ada.Numerics.Float_Random;
use Ada.Numerics.Float_Random;
package random is

   protected randomOut is
      procedure Inicializal;
      entry Parcel(
                randomout: out Positive;
                from: in Positive;
                to: in Positive := 1
               );
   private
      G: Generator;
      Inicializalt: Boolean := False;
   end randomOut;

   task print is
      entry write(what: in String);
   end print;

end random;
Run Code Online (Sandbox Code Playgroud)

.gpr文件如下所示:

project Default is
   package Compiler is
      for Default_Switches ("ada") use ("-g", "-O2");
   end Compiler;

   for Main use ("hunting.adb"); …
Run Code Online (Sandbox Code Playgroud)

ada gnat

0
推荐指数
1
解决办法
1373
查看次数

来自Ada的"操作符号不允许通用子程序"

我想制作用Ada添加数组元素的子程序.子程序"Add_Data"有3个参数 - 第一个参数=泛型类型数组(INTEGER数组或REAL数组)第二个参数= INTEGER(数组大小)第三个参数=泛型类型sum(INTEGER数组 - > sum将是INTEGER,数组真实 - >总和将是真实的)

我是从ideone.com编程的.(我想通过INTEGER数组看到结果.之后,我将通过REAL数组进行测试)

With Ada.Text_IO; Use Ada.Text_IO;  
With Ada.Integer_Text_IO; Use Ada.Integer_Text_IO;
procedure test is
   generic 
      type T is private;
      type Tarr is array (INTEGER range <>) of T;
      --function "+" (A,B : T) return T;
      --function "+" (A, B : T) return T is
      --begin
      --   return (A+B);
      --end "+";
   procedure Add_Data(X : in Tarr; Y : in INTEGER; Z : in out T);

   procedure Add_Data(X : in Tarr; Y : in INTEGER; …
Run Code Online (Sandbox Code Playgroud)

operator-overloading ada

0
推荐指数
1
解决办法
169
查看次数