ada

Can you call Ada functions from C++?

这一生的挚爱 提交于 2019-12-04 08:41:43
I'm a complete Ada newbie, though I've used Pascal for 2-3 years during HS. IIRC, it is possible to call Pascal compiled functions from C/C++. Is it possible to call procedures & functions written in Ada from C++? VonC According to this old tutorial , it should be possible. However, as illustrated by this thread , you must be careful with the c++ extern "C" definitions of your Ada functions. Here's an example using g++/gnatmake 5.3.0: NOTE: Be careful when passing data between C++ and Ada ada_pkg.ads package Ada_Pkg is procedure DoSomething (Number : in Integer); pragma Export (C, DoSomething,

Arbitrary length integer in Ada

偶尔善良 提交于 2019-12-04 06:46:03
I am currently teaching myself Ada and though I could begin by tackling some of the more conventional problems to get started. More specifically I try to calculate the factorial n!, whereas n>100. My implementation so far is: with Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Text_IO; procedure Factorial is -- define a type covering the range beginning at 1 up to which faculty is to -- be computed. subtype Argument is Long_Long_Integer range 1..100; -- define a type that is large enough to hold the result subtype Result is Long_Long_Integer range 1..Long_Long_Integer'Last; package Result_IO

Troubles compiling in GPS (Ada IDE) with glib.h

此生再无相见时 提交于 2019-12-04 04:52:29
问题 i'm having some troubles when trying to compile Ada code in GPS. GPS says is missing when I include it on a package. I tried installing with apt-get, and it does, but the error is still there. What can I do next? I'm running GPS on a x64 Ubuntu 12.04. Here's the error message I got: gprbuild -d -P/media/LUISMUNYOZ/QUINTO/str/pendulum/pendulum_portatil/pendulum.gpr -XEXTRA=True -XOPENGL=True -XGNOME=True -XBUILD=Production print_barrier_sync.adb contrib.gpr:1:09: warning: no compiler specified

Derived types and sub types in Ada

无人久伴 提交于 2019-12-04 03:37:33
问题 What are the differences? 回答1: First of all, terminology: it's "Ada", not "ADA" -- it's named after "Ada Lovelace"; it is not an acronym. A subtype is compatible with its base type, so you can mix operands of the base type with operands of the base type. For example: subtype Week_Days is Integer range 1..7; Since this is a subtype, you can (for example) add 1 to a weekday to get the next weekday. A derived type is a completely separate type that has the same characteristics as its base type.

Does Ada real-time need an underlying operating system?

本秂侑毒 提交于 2019-12-04 03:35:07
From what I have understood by reading the documentation, the Ada real-time module works completely isolated from the OS. It's possible to have concurrency without having an underlying OS and a resource manager. Ada handles task dispatching, time management, task state transition, list managements, task priority, locking policies, scheduling policies, ISR, inter task communication, etc. If so then Ada real-time module is kind of a real-time operating system? Both yes and no. What an Ada program needs is its own RTS (Runtime System) - the fairly large chunk of code that (in another recent

Loading Ada shared objects in Perl with DynaLoader.pm

不打扰是莪最后的温柔 提交于 2019-12-04 01:16:23
Long time listener, first time caller. I'm aware this is a somewhat obscure question, and don't expect too much. :-) I have the following Ada files: greeter.ads package Greeter is procedure Hello; end Greeter; greeter.adb with Ada.Text_IO; use Ada.Text_IO; package body Greeter is procedure Hello is begin Put_Line ("Hello, world!"); end Hello; end Greeter; And compile them into a shared object like this: gnatmake -z -fPIC greeter.adb gcc -shared -o libgreeter.so greeter.o This compiles fine. nm shows the following symbols: $ nm -D libgreeter.so w _Jv_RegisterClasses 0000000000201028 A __bss

Cancel space after Integer'Image value in Ada

别说谁变了你拦得住时间么 提交于 2019-12-04 01:11:31
问题 when I'm print this procedure below - procedure put (Date:Date_Type) is begin Put(Integer'Image(Date.Day)); --' Put("-"); Put(Integer'Image(Date.Month)); --' Put("-"); Put(Integer'Image(Date.Year)); --' end; The result is (for example) : 1- 1- 2010 My question is how to prevent the spacing of one character before every Date value. (day/month/year). Of course I'm using Date procedure with record inside holding day/month/year. Thanks in advance. 回答1: You have a few options: If you know the

Ada: Fraction part of Float/Fixed as Integer

佐手、 提交于 2019-12-02 21:37:09
问题 In Ada, I would like to separate out a number like 12.345 out into two distinct integers: whole : integer := 12; fraction : integer := 345; The Whole part is easy, but I don't know how to get the Fraction part. My starting idea is: 12.345 mod Integer(12.345) which will return 0.345, and could be multiplied by the inverse magnitude (in this case ×1000), but I don't know how to count the amount of digits either. 回答1: Not a full Answer but this gets the fractional part as a string to enable

What is “Subtype mark required in this context” exactly?

久未见 提交于 2019-12-02 13:01:23
问题 I get Subtype mark required in this context at (*) . What exactly is subtype mask and why is it complaining here? main.adb (*)Open_Route : Route(1..3) := (others => new Location(X=>1.0,Y=>1.0, id=>1)); -- Closed_Route : Route (Open_Route'First .. Open_Route'Last + 1); -- P1 : Population (1..2); Location.ads package spec type Location is record Id : Positive; X : Float; Y : Float; end record; type Location_Acess is access all Location; type Route is array (Positive range<>) of Location_Acess;

Ada: Fraction part of Float/Fixed as Integer

妖精的绣舞 提交于 2019-12-02 12:57:18
In Ada, I would like to separate out a number like 12.345 out into two distinct integers: whole : integer := 12; fraction : integer := 345; The Whole part is easy, but I don't know how to get the Fraction part. My starting idea is: 12.345 mod Integer(12.345) which will return 0.345, and could be multiplied by the inverse magnitude (in this case ×1000), but I don't know how to count the amount of digits either. Not a full Answer but this gets the fractional part as a string to enable further manipulation to retreive it as an integer: with Ada.Text_Io; procedure Remainder is package Fio is new