ada

Variable initialization in generic package body using return value of function

时光总嘲笑我的痴心妄想 提交于 2019-12-13 08:38:20
问题 In Ada, I have the following spec file: GENERIC TYPE Item IS PRIVATE; --type of array size : integer; --size of array PACKAGE gwar IS function get_size return integer; END gwar; And body file: with Ada.Text_Io; use Ada.Text_Io; package body gwar is --Get_Size allows the txt file to specify how much space to allocate. function get_size return Integer is Filename : String := "win.txt"; File : Ada.Text_IO.File_Type; Line_Count : Integer := 0; ReturnSize : Integer; begin Ada.Text_IO.Open(File =>

How to create a dynamically allocated array in Ada?

梦想的初衷 提交于 2019-12-13 08:02:52
问题 As the questions says, I want to create a dynamically allocated array in Ada. Something like C++ std::vector ie., I don't want to store the length of the array in a separate variable like it is done here. As Ada supports generics, is it possible to create a std::vector like functionality in Ada? 回答1: The Standard Libraries includes Ada.Containers.Vectors (RM A.18.2) 来源: https://stackoverflow.com/questions/29294854/how-to-create-a-dynamically-allocated-array-in-ada

Ada - getting string from text file and store in array

▼魔方 西西 提交于 2019-12-13 06:01:09
问题 Hi im just wondering how to put data in an array if i loop txt and store it in A_Composite Name. procedure Main is type An_Array is array (Natural range <>) of A_Composite; type A_Composite is record Name : Unbounded_String; end record; File : Ada.Text_IO.File_Type; Line_Count : Integer := 0; begin Ada.Text_IO.Open (File => File, Mode => Ada.Text_IO.In_File, Name => "highscore.txt"); while not Ada.Text_IO.End_Of_File (File) loop declare Line :String := Ada.Text_IO.Get_Line (File); begin --I

What caused this Ada compilation error “ambiguous character literal”?

南笙酒味 提交于 2019-12-13 05:02:23
问题 I have this Ada code. with Ada.Text_IO; use Ada.Text_IO; procedure for_Loop is begin for Counter in 'A'..'Z' loop Put(Counter); end loop; New_Line; end for_Loop; The Ada compiler (gnatmake) outputs these error message. gcc -c for_loop.adb for_loop.adb:6:24: ambiguous character literal for_loop.adb:6:24: possible interpretation: Character for_loop.adb:6:24: possible interpretation: Wide_Character for_loop.adb:6:24: possible interpretation: Wide_Wide_Character gnatmake: "for_loop.adb"

Calling Ada from C++ in Eclipse

浪尽此生 提交于 2019-12-12 21:59:39
问题 I am trying to create a program that is completely hosted in Eclipse, starts in C++, and calls Ada. I have GNATBench loaded, and can run Ada programs without a problem. What I cannot do is have a C++ project call an Ada project. After hunting around, I found and executed the code shown below using a make file. http://www.pegasoft.ca/resources/boblap/book.html I also found a post stating that my goal has been done. http://blogs.windriver.com/parkinson/2009/10/yesterday-adacore-announced-the

UTF-8 on Windows with Ada

强颜欢笑 提交于 2019-12-12 20:14:43
问题 It is my understanding that by default, Character is Latin_1, Wide_Character is UCS-2, and Wide_Wide_Character is UCS-4, but that GNAT can have specified pragma Wide_Character_Encoding(UTF8); or -gnatW8 and that those characters and their strings will be UTF-8 encoded instead. At least on Linux and FreeBSD, the results fit with my expectations. But on Windows the results are odd. For either Wide or Wide_Wide variants, once a character moves beyond the ASCII set, I get a garbled mess. I

ADA File Names vs. Package Names

佐手、 提交于 2019-12-12 19:27:57
问题 I inherited an ADA program where the source file names and package file names don't follow the default naming convention. ADA is new to me, so I may be missing something simple, but I can't see it in the GNAT Pro User's Guide. (This similar question didn't help me.) Here are a couple of examples: File Name: C_Comm_Config_S.Ada Package Name: Comm_Configuration File Name: D_Bus_Buffers_S.Ada Package Name: Bus_Buffers I think I have the _S.Ada and _B.Ada sorted out, but I can't find anything in

How is inheritance implemented in Ada and does it have built in GUI?

空扰寡人 提交于 2019-12-12 19:19:19
问题 Does Ada come with built-in GUI, and does it have the same unique approach to inheritance as does Oberon? 回答1: No, Ada does not come with a built-in GUI; but then the closest language that I can think of is PostScript. (Technically, the Java-language does not; though its included library does.) That being said there is a GTK binding (which I haven't used at all) and an OpenGL binding (that I've only played with; and to be honest the OpenGL binding is far thinner a binding than I'd like).

What is the usefulness of the `access` parameter mode?

ぃ、小莉子 提交于 2019-12-12 19:14:31
问题 There are three 'normal' modes of passing parameters in Ada: in , out , and in out . But then there's a fourth mode, access … is there anything wherein they're required? (i.e. something that would otherwise be impossible.) Now, I do know that the GNAT JVM Ada-compiler makes pretty heavy use of them in the imported [library] specifications. (Also, they could arguably be seen as essential for C/C++ translations.) 回答1: One of the primary drivers of the access mode was to work-around the

Defining a generic scalar-type package in Ada

限于喜欢 提交于 2019-12-12 14:52:44
问题 I'd like to test the waters of writing Ada packages by making one for manipulating polynomials. Polynomials can be defined for a wide class of algebraic structures, so to reflect this, I'd like to make the package generic, so it can be used with Floats, Integers, or other numeric sub-types. I want to say now that I know very little about how Ada's type system work or how its package system works. There seems to be a lack of good beginner Ada inforamtion on the web, so I'm having to glean what