ada

Ada: Writing to files within a block statement

痴心易碎 提交于 2019-12-20 02:13:41
问题 I am dealing with an array whose length is determined during the execution of the program. So I am making use of a block statement in which I can set the limits of the array. I am having problems to write the elements of the array to a file as I was using a stub for the write procedure . I removed the stub to have everything in the same code. Though now my code compiles and run , it is not writing to the file. Here is the code: with Ada.Float_Text_IO; with Ada.Integer_Text_IO; with Ada.Text

Access type declaration effect on deallocation

亡梦爱人 提交于 2019-12-19 11:29:38
问题 Is the memory freed the same way after the declare block (and before the end of the procedure of course) in both cases: procedure allocation is type T_Integer_Access is access Integer; begin declare P : T_Integer_Access; begin P := new Integer'(5); end; end; procedure allocation is begin declare type T_Integer_Access is access Integer; P : T_Integer_Access; begin P := new Integer'(5); end; end; Put another way, has the access type declaration an effect on memory deallocation? 回答1: There’s a

How to bind to OpenCV for GNAT?

余生长醉 提交于 2019-12-18 09:08:46
问题 Can anybody tell me how to find or create a binding to OpenCV for GNAT? I want to use Ada2005 to implement some program with OpenCV (1.0 or 2.X), but I don't know how. Can anybody teach me how to do it? 回答1: Teaching you how to create a binding to a complex library is beyond the scope of StackOverflow, but you might start with this tutorial. Then study the relevant GNAT library sources, e.g. Ada.Numerics , and other existing Ada bindings. Among others, Ada 2005 Math Extensions and An Ada

How to bind to OpenCV for GNAT?

别等时光非礼了梦想. 提交于 2019-12-18 09:08:17
问题 Can anybody tell me how to find or create a binding to OpenCV for GNAT? I want to use Ada2005 to implement some program with OpenCV (1.0 or 2.X), but I don't know how. Can anybody teach me how to do it? 回答1: Teaching you how to create a binding to a complex library is beyond the scope of StackOverflow, but you might start with this tutorial. Then study the relevant GNAT library sources, e.g. Ada.Numerics , and other existing Ada bindings. Among others, Ada 2005 Math Extensions and An Ada

dynamic array size determined at runtime in ada

青春壹個敷衍的年華 提交于 2019-12-18 06:06:26
问题 Is it possible to have an array with size that is determined at runtime like so, Procedure prog is type myArray is array(Integer range <>) of Float; arraySize : Integer := 0; theArray : myArray(0..arraySize); Begin -- Get Array size from user. put_line("How big would you like the array?"); get(arraySize); For I in 0..arraySize Loop theArray(I) := 1.2 * I; End Loop; End prog; Is there a way to achieve this result other than using dynamically Linked Lists or another similar structure? Or is

Enum in C++ like Enum in Ada?

眉间皱痕 提交于 2019-12-17 16:00:15
问题 At one point I had looked at implementing a class/template in C++ that would support an Enum that would behave like it does in Ada. It has been some time since I thought about this problem and I was wondering if anyone has ever solved this problem? EDIT: My apologies, I should clarify what functionality I thought were useful in the Ada implementation of the Enum. Given the enumeration type fruit is (apple, banana, cherry, peach, grape); We know that fruit is one of the listed fruits: apple,

Separate declarations of types/packages aliases in Ada

北慕城南 提交于 2019-12-14 03:56:12
问题 I would like to declare some "user-defined compiler-constants" to keep my specification files as "constant" as possible. This is something common in C++, e.g. : // misc/config.hh namespace misc { typedef std::shared_ptr<A> A_ptr; namespace arch = ibmpc; } // misc/code.hh #include "misc/config.hh" namespace misc { void function p(A_ptr a); } Which would be in Ada : -- misc.ads package Misc is use Types; ----> forbidden ! procedure P(A : A_Access); end Misc; -- misc-types.ads package Misc.Types

How to stop execution in my program

大憨熊 提交于 2019-12-14 01:18:34
问题 Without copy-pasting my code here, how can I stop my ADA program from executing anymore lines of code during run-time if it calculates a certain value to 'X'? something like: variable_name := variable_name +4; if variable_name >1 then // END program here and dont execute any lines under this one end if I am not new to programming but new to ADA so finding the correct syntax is a pain. Any help? 回答1: There isn’t any specific syntax for this. If you are in the main procedure, a simple return

Piping to/from Ada program to a C++ program

柔情痞子 提交于 2019-12-14 00:33:58
问题 I have used pipes in C/C++ before but I'm working on setting up a pipe in some legacy Ada code...however I am still in the "learning" phase with Ada and there's a lot I still don't yet know. That being said, I've been trying to figure out how pipes in Ada are setup & how to go about using them. I've only found these articles thus far: A Thick Ada 95 Binding for Unix Child Processes and Pipes Package: Util.Pipes Pipes - ada-util. Don't get me wrong they have a lot of good knowledge in them,

Sparc Function compilation alignment

半城伤御伤魂 提交于 2019-12-13 12:50:37
问题 I want my program such that each function in the binary has some space left after it ends. So that later if some minor change is required only that function is changed with the extra space acting as room for accounting the minor change. -falign-function can do the job but it will not give consistent space. Is there anyway to do it? Or better way to do it? 回答1: You could use an inline assembly statement to add a series of nops at the start (or end) of each function. Then later when you need to