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
1
vote
2 answers

Printing coloured text in Ada -- ANSI escape codes seem impossible to get working

I'd like to use ANSI escape sequences to print styled text in Ada. This is what I've tried: with Ada.Text_IO; use Ada.Text_IO; with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; procedure Main is begin -- No ESC character …
haz
  • 2,034
  • 4
  • 28
  • 52
1
vote
1 answer

How can I assign record x to record y with a single change?

Take the following example: type MyArray is array(1..10) of Float; type MyRecord is record a: Float; b: Integer; c: Boolean; d: MyArray; end record; … function foo(x: MyRecord) return MyRecord is y:…
Ben Hocking
  • 7,790
  • 5
  • 37
  • 52
1
vote
2 answers

ada get_line of arrays (1..5) of string(1..10)

I have a problem. I have made an array of string because I want to store some names in an array. The problem is, when I write name shorter the 10 characters, the program fill the array with random characters up to 10. And I don't know how to solve…
1
vote
1 answer

Why does this Ada program not throw a constraint error?

I expected the following code to throw a constraint error on compilation, however it didn't. It also does not throw a runtime error on the c2 assignment. Edit: Running the compiler with -gnata solves the compilation warning issue, but does not solve…
user3117351
  • 141
  • 1
  • 1
  • 9
1
vote
2 answers

Why is this Java program 1000 times faster than its Ada equivalent?

I have two programs that simply loop a billion times and increment an integer. I am timing both of the operations and comparing the two results. For the Ada program, I am using the GNAT FSF compiler. Both programs are run on Windows. I have also…
user3117351
  • 141
  • 1
  • 1
  • 9
1
vote
3 answers

What is the type of the index of an array using a range as its index?

Given the following array definition: type A is array (1 .. 10) of INTEGER; And the following generic: generic type LENGTH_T is range <>; type INDEX_T is (<>); type ELEMENT_T is limited private; type ARRAY_T is array (INDEX_T) of…
Markus
  • 3,155
  • 2
  • 23
  • 33
1
vote
2 answers

Generate functions at compile-time

Is there any way to generate functions at compile-time in Ada? I want to generate an opcode table that stores function pointers. My current solution is to store objects containing a procedure that can be executed, but I'd rather not allocate if…
Arcterus
  • 13
  • 2
1
vote
0 answers

Ada/C: Segfault before main with no core dump. Valgrind Invalid read of size 4

I recently had a merge with another program and not it seg faults immediately. It is majority ada and the errors looks like this. Execution terminated by unhandled exception raised STORAGE_ERROR : s-intman.adb:136 explicit raise Call stack traceback…
JDiGz
  • 23
  • 5
1
vote
2 answers

Heterogeneous tuple in Ada

Is it possible in ada to create a heterogeneous tuple on the stack without the new operator and access types? I need to make N 2-d arrays depending on a known number in compile time. To be more precise, a certain number of tensors depends on the…
1
vote
1 answer

Installer for GNAT 2018 community version for x86-64 Mac OS X does not complete

The installer runs for a while and many files get installed but it hangs. There is a choice of installing the GNAT compiler tool chain, SPARK tool set and GPS development environment. I've tried it with just the compiler and with all three. Both…
Wayne B.
  • 7
  • 1
  • 1
1
vote
1 answer

Implement an interface with class wide operations in Ada 95

I'm creating a program with Ada 95 and I have a problem. Specifically, I'm trying to implement a class which executes functors given as parameters. The behavior I want to achieve is: Declare an interface IF with a procedure Execute. Derive from IF…
Dan
  • 2,452
  • 20
  • 45
1
vote
1 answer

List of Child Elements of a Element in ASIS(Ada Semantics interface Specification)

I am implementing a simple tool using ASIS(Ada Semantics interface Specifications). I am having problem with listing child elements in a given Elements.for example i am having assignment statement as C := A + B; i am able to get the…
1
vote
2 answers

Ada equivalent of Python's dir() method

Is there a way of seeing attributes of a type in Ada? I've not been able to find anything so far. I'd like to be able to pass a type into a generic function with some corresponding XML and parse one to the other without writing a bespoke function…
David Boshton
  • 2,555
  • 5
  • 30
  • 51
1
vote
1 answer

Ada - Subtype mark required in this context

I'm trying to make a simple looping program but get the error on line 18, subtype mark required in this context, but I don't get this error when running other programs? with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use…
Bliwiker
  • 15
  • 3
1
vote
1 answer

Ada - access constant confusion

Say I have a type: type A; type XA is access constant A; type A is record Member : Natural := 1; Neighbor : XA; end record; I'm confused about the access constant part. If I instantiate a instance of XA that points to a instance…
zython
  • 1,176
  • 4
  • 22
  • 50