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
1 answer

How to set tab indentation with GNAT GPS

I installed GNAT GPS 2017 and I would like it to indent my code with tabs using the same width as 4 space characters. I've gone into Edit->Preferences->Editor->Ada and tried all sorts of options (Use tabulations, default indentation 4, etc) but…
user8996961
1
vote
1 answer

Debugging gdb - listing source directories in use

Trying to debug an ada program, gdb doesn't seem to be able to locate a source. I did confirm that the running executable was the same one that was just built. Upon attach, it displays the following in the console, when instead it should take me to…
theMayer
  • 15,456
  • 7
  • 58
  • 90
1
vote
2 answers

Ada functions, accessing stack

Very new with Ada, this is my first time coding with it. Very lost. Any tips, and direction would be great. Ada question: I am trying to make: the function Top (S : Stack) return Item_Type, which returns the top item on the stack or raises the…
theSpleen
  • 13
  • 3
1
vote
2 answers

Creating a 2D-Array Field in an Ada Tagged Type

I'm trying to create a Java/C class equivalent in Ada. From what I've researched -- the equivalent would be a Tagged Record. I'm wanting to create a field that is a 2D Array, however with the code below -- it gives me the following…
CaesiumWhale
  • 95
  • 1
  • 6
1
vote
1 answer

Ada95 Loop through Array within a Record and print the characters

The program below is suppose to get an input of Characters from the user and put it into an Record with the subprogram Procedure Get(Tecken : out Record_Type). The last step is to Print it in the Terminal with another subprogram Procedure Put(Chars…
R.Englund
  • 21
  • 5
1
vote
1 answer

Any way to statically initialize an Ada 2012 Map

I'm trying to create a global map that can be referenced by a procedure building a level. It would be ideal if this global map could be populated statically in the specification (.ads). Here's some broken code of me trying to guess how to do the…
1
vote
1 answer

Array of strings in Ada record

I have the following record in some Ada code: type My_Type (Width, Height : Positive) is record Data : array (1 .. Height) of String (1 .. Width); -- Some other stuff end record; Of course I can't have anonymous arrays in…
LambdaBeta
  • 1,479
  • 1
  • 13
  • 25
1
vote
1 answer

Ada95: Recursive function for Bernoulli numbers

I'm trying to code a function that calculates the N'th value of the positive Bernouille numbers. I want to do it with this recursive formula: What I've tried so far: function Get_B(N : in Integer) return Float is X,Bn,Bk:Float; begin …
Ludd
  • 53
  • 5
1
vote
1 answer

Ada: package linking error

I have a problem with my project. The issue problem with linking a package and visibility of the tasks. in bufor1.ads package bufor1 is task type Bufor is entry Przyjmij(Wyrob: in Typ_Wyrobow; Numer: in Integer); entry…
1
vote
1 answer

Creation of controlled type will call finalize on return

I want to create a function for creating and initializing a controlled type (a bit like a factory) in the following manner: function Create return Controlled_Type is Foo : Controlled_Type; begin Put_Line ("Check 1") return Foo; end…
Erik Stens
  • 1,779
  • 6
  • 25
  • 40
1
vote
1 answer

Ada code layout with gnatpp query

I am trying to use gnatpp to improve the layout of some ada code, however when reformatting procedure calls it is putting named parameters on the same line, rather than on separate lines as I prefer. The switches I am using are : gnatpp $(INCLUDES)…
NWS
  • 3,080
  • 1
  • 19
  • 34
1
vote
1 answer

Nested "then abort" weird behaviour

Are nested "then abort" constructions legal in Ada? If yes, how properly can I use them? I have this code: with Ada.Text_IO; use Ada.Text_IO; procedure Main is task TestTask is end TestTask; task body TestTask is begin select …
1
vote
2 answers

Trying to make a function generic, but getting hung up

I have a variable in a package (rec in this case) that needs to be set when called from package 3, but it's private. Previously the function set_true only set rec to true, so it wasn't a big deal. But I have another package that does the same…
onaclov2000
  • 5,741
  • 9
  • 40
  • 54
1
vote
1 answer

Ada- raised Constraint_error : bad input for 'Value:

I'm trying to use Integer'Value to convert a string to an Integer. This works fine for the first loop through a file, but after that I get a bad input for 'value (raised Constraint_Error. I was hoping someone could show me the error of my ways, so…
Justiciar
  • 356
  • 1
  • 3
  • 20
1
vote
1 answer

Ada gprbuild hangs on initialization

I have no idea why suddenly my gprbuild is getting stuck. Here's a pretty straightforward way to replicate what I'm seeing: mkdir test mkdir build printf 'with Ada.Text_IO; use Ada.Text_IO;\nprocedure Main is begin Put_Line ("Hello, World!"); end…
LambdaBeta
  • 1,479
  • 1
  • 13
  • 25