Questions tagged [ada]

Ada is a structured, statically typed, imperative, wide-spectrum, and object-oriented high-level computer programming language, extended from Pascal and other languages.

Ada is a structured, statically typed, imperative, wide-spectrum, and object-oriented high-level computer programming language, extended from Pascal and other languages.Wikipedia

New to Ada?

Welcome! For learning any language, starting off with a good book is highly recommended. Ada is no different. Ada is different however in the number and quality of online resources available for free. A good starting point is the list of Ada Books On-Line. Once you have some basic learning under your belt, many find Ada LRM to be all the reference they ever need. The Ada Information Clearinghouse also provides a lot of useful links for learning Ada.

If you are looking for a good compiler, GNAT is a production-quality GCC-based Ada compiler that is freely available for Windows, OS X, and Linux; more here. Support and more platforms are available from AdaCore. If you want a more Windows-native compiler, Aonix ObjectAda uses the Microsoft linker, so it can be easier to use in an integrated Windows environment.

Versions

There are multiple versions of the language, named based on the year the ISO standardized the language. Thus there currently are Ada83, Ada95, Ada2005 and Ada2012. Any of those can be referenced as Ada, although the term is more appropriate for the latest version of the language.

Have a question?

When you ask a question, be sure to include any relevant source code. Try to keep the code as minimalist as possible while still reproducing the problem; often the problem will be found during the process. If there are any compiler errors, be sure to indicate:

  • Which compiler you are using?
  • Exactly what errors are shown?
  • On which lines do they occur (mark the lines with comment)?

It is recommended to enable syntax highlighting in the source code that you add to the question. Use the following syntax:

``` lang-ada
-- Ada source code goes here
```

External FAQs

Other External Resources

2354 questions
9
votes
1 answer

Ada equivalent of local static variable from C/C++

I'm coming from C/C++ on embedded systems and all the time inside a function we use a static variable so that the value is retained throughout calls. In Ada, it seems like this is only done with the equivalent of file-level static variables. Is…
Awaken
  • 1,243
  • 2
  • 14
  • 26
9
votes
2 answers

Ada: Getting user input to a String(1..10) and filling the rest with whitespace

I have defined subtype String10 is String(1..10); and I am attempting to get keyboard input to it without having to manually enter whitespace before hitting enter. I tried get_line() but from some reason it wouldn't actually wait for input before…
user1279914
  • 185
  • 1
  • 5
  • 19
9
votes
4 answers

Non-contiguous ranges for subtypes in Ada?

Totally as an Ada-type-system learning exercise, I was trying to make 3 types (or rather, a type and 2 subtypes): Month_Type, an enumeration of all months Short_Month_Type, a Month_Type subtype only having the months with 30…
J Cooper
  • 16,891
  • 12
  • 65
  • 110
8
votes
1 answer

How to prove this invariant?

I aim to prove that the Horner's Rule is correct. To do so, I compare the value currently calculated by Horner with the value of "real" polynominal. So I made this piece of code: package body Poly with SPARK_Mode is function Horner (X : Integer;…
8
votes
4 answers

Aggregate Initialization Safety in C++

Suppose I have the following struct: struct sampleData { int x; int y; }; And when used, I want to initialize variables of sampleData type to a known state. sampleData sample = { 1, 2 } Later, I decide that I need additional data…
Greg
  • 1,480
  • 3
  • 15
  • 29
8
votes
2 answers

Ada entry and when statement usage

I am a newbie in Ada programming language and I am working on concurrent programming, but I am having a problem with one implementation. This might be very dummy question. The code is: type status is array(1..6) of boolean; --boolean values for each…
Ahmet Keskin
  • 1,025
  • 1
  • 15
  • 25
8
votes
1 answer

Semaphore in Ada

This is an assignment and I have been asked to implement a Semaphore in Ada as the description below. However I have implemented the Semaphore.adb and called this Semaphore in the producerconsumer_sem.adb which I created. I get some output which is…
Adam
  • 856
  • 2
  • 9
  • 18
8
votes
1 answer

Does Ada real-time need an underlying operating system?

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…
user3707950
8
votes
1 answer

How to create an ada lib.a and link to C

I am trying to create an ada library and have tried a few different things. I have tried compiling the project using makefiles and trying to create a library from all the .o files This seemed to not work as expected. I then asked adacore support…
crychair
  • 337
  • 3
  • 20
8
votes
4 answers

Can you call Ada functions from C++?

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++?
oz10
  • 153,307
  • 27
  • 93
  • 128
8
votes
1 answer

Ada cross-compiler for iOS targets

tl;dr How can I compile Ada source code to a static library file suitable for apps on iPad targets running iOS to link against? (GCC is not a requirement. Solutions using LLVM or others are also welcome!) I have a large library of portable Ada code…
ardnew
  • 2,028
  • 20
  • 29
8
votes
5 answers

How to I build a string from other strings in Ada?

I want to output a header line in a log file and then a line of '-' before the data. To do this I create a string of the header and then outpout the same number of '-'. But the below code always fails with a CONSTRAINT_ERROR because the generated…
mat_geek
  • 2,481
  • 3
  • 24
  • 29
8
votes
2 answers

Defining a modular type within a generic package

In brief, why doesnt this work: generic Max : in Positive; package Modular_Gen_Issue is procedure Foo; private type Mod_Thing is mod Max; -- NOK type Int_Thing is new Integer range 0 .. Max; -- OK end Modular_Gen_Issue; With…
NWS
  • 3,080
  • 1
  • 19
  • 34
8
votes
1 answer

What is the tick or apostrophe character for in Ada?

Very basic question, but just reading through source code and trying to tell what the ' is for and how it differs from .
J Cooper
  • 16,891
  • 12
  • 65
  • 110
8
votes
3 answers

An Erlang written in Ada?

Another thread had this quote Erlang VM BEAM and HiPE is written mostly in C. Linked-in drivers are written mostly in C. (They are plugged to VM and serves communication with outside world.) I've read some opinions that Ada's strong typing,…
Paulb
  • 1,471
  • 2
  • 16
  • 39