ada

Quadratic equation in Ada

笑着哭i 提交于 2020-01-09 05:07:10
问题 I just came around and decided to try some Ada. The downside is that the syntax and function strays quite away from C++. So I had to like cram various stuff to get this thing to work. My question is if there are some better way to do this calculation that what I have done here IF(B < 0.0) THEN B := ABS(B); X1 := (B / 2.0) + Sqrt( (B / 2.0) ** 2.0 + ABS(C)); X2 := (B / 2.0) - Sqrt( (B / 2.0) ** 2.0 + ABS(C)); ELSE X1 := -(B / 2.0) + Sqrt( (B / 2.0) ** 2.0 - C); X2 := -(B / 2.0) - Sqrt( (B / 2

TCP/IP using Ada Sockets: How to correctly finish a packet? [duplicate]

老子叫甜甜 提交于 2020-01-06 06:56:19
问题 This question already has answers here : TCP Connection Seems to Receive Incomplete Data (5 answers) Closed 3 months ago . I'm attempting to implement the Remote Frame Buffer protocol using Ada's Sockets library and I'm having trouble controlling the length of the packets that I'm sending. I'm following the RFC 6143 specification (https://tools.ietf.org/pdf/rfc6143.pdf), see comments in the code for section numbers... -- Section 7.1.1 String'Write (Comms, Protocol_Version); Put_Line ("Server

Shortened method to reduce statements in an Ada procedure?

心已入冬 提交于 2020-01-06 03:37:05
问题 I am creating a procedure that uses an if statement to perform a decision. I have four variables: Altitude , Velocity , Angle and Temperature . The procedure is as follows: procedure Test3 is begin if (Integer(Status_System.Altitude_Measured)) >= Critical_Altitude and (Integer(Status_System.Velocity_Measured)) >= Critical_Velocity and (Integer(Status_System.Angle_Measured)) >= Critical_Angle and (Integer(Status_System.Temperature_Measured)) >= Critical_Temperature then DT_Put ("message 1");

Illegal declaration in task definition

半世苍凉 提交于 2020-01-06 01:45:14
问题 I have the following task specification: with Ada.Real_Time; use Ada.Real_Time; package pkg_task is task type task_t is activationTime : constant Integer := 1; period : constant Integer := 2; computingTime : constant Integer := 1; startingTime : Time; end task_t; end pkg_task; When I compile I obtain the error mentioned on the title in all the lines of the task specification where I declare the variables, and I don't know what is the problem. 回答1: As Jacob wrote, you can't export anything

List unused files in Gnat

好久不见. 提交于 2020-01-05 04:13:06
问题 I have a project in GNAT and I would like to list all the files that are never used. I am thinking about doing it with a python script, but, is it possible to do so easily with GNAT? Update: I found about gnatelim, but although in the help it says to have the -P option usage: gnatelim [options] -main=main_unit_name {filename} [-cargs gcc_switches] options: --version - Display version and exit --help - Display usage and exit -Pproject - Use project file project. Only one such switch can be

Rename an Ada package

不想你离开。 提交于 2020-01-05 04:00:32
问题 Is it possible to have a different file name for a package than its actual name? I have tried to use the pragmas below but get errors like "pragma source_file_name_project argument has incorrect identifier" package Parent_With_Very_Long_Name is end Parent_with_Very_Long_Name; ... package Parent_With_Very_Long_Name.Child is pragma Source_File_Name_Project("parent-child.ads"); end Parent_With_Very_Long_Name.Child; Source_File_Name_Project Source_File_Name 回答1: The actual storage of Ada source

Why is implicit conversion between anonymous access objects disallowed in Ada?

怎甘沉沦 提交于 2020-01-04 05:15:12
问题 I am working my way through Barnes' book 'Programming in Ada 2012'. This is a code sample implementing a stack from section 12.5. src/stacks.adb: (the main relevant file) package body Stacks is procedure Push(S: in out Stack; X: in Integer) is begin S := new Cell'(S,X); end Push; procedure Pop(S: in out Stack; X: in out Integer) is begin X := S.Value; S := Stack(S.Next); end Pop; function "="(S, T: Stack) return Boolean is SS: access Cell := S; TT: access Cell := T; begin while SS /= null and

Ada compiler GNAT on Mac OS

血红的双手。 提交于 2020-01-03 17:01:57
问题 I'm trying to compile ada using the terminal on my mac but I always get this error "error: invalid value 'ada' in '-x ada' " anyone knows how can I fix this? 回答1: You probably don't have an Ada compiler installed, the gcc that comes with OSX does not support Ada. Currently, there are two flavors of free Ada-enabled gcc binaries for OSX: GNAT GPL from AdaCore (select x86_64-darwin as platform). This compiler and the accompanying runtime library are licensed under the GPL, meaning that if you

Passing strings in C-ADA binding application

旧城冷巷雨未停 提交于 2020-01-03 05:36:12
问题 How can I pass strings from a C function to function in ADA (C-ADA binding)? Any examples would be appreciated. 回答1: Basically, you would create a subprogram on the Ada side that maps you C function: procedure Foo (C : Interfaces.C.Strings.chars_ptr); pragma import (C, Foo, "foo"); so that from Ada you have access to foo() . The custom is to then provide a more Ada friendly version, with: procedure Foo (C : String) is S : Interfaces.C.Strings.chars_ptr := New_String (C); begin Foo (S); Free

Procedure to open, write and append in Ada

半城伤御伤魂 提交于 2020-01-02 10:00:43
问题 This question is a follow-up of the post at Ada file operation: instantiation and exception about writing to files in Ada. I chose to place this question in a separate post so that it'll become visible to more people as I already accepted an answer on a slightly different issue (which was on exceptions in file handling) in that aforementioned post. WITH Ada.Sequential_IO; WITH Ada.Float_Text_IO; PROCEDURE TEST is package Seq_Float_IO is new Ada.Sequential_IO (Element_Type => Float); X_File :