2,447 questions
0
votes
2
answers
84
views
gcc/g++ compiler with POSIX thread model
I'm on Windows OS and in the past month I used to compile a C/C++ project in Qt Creator IDE using MinGW's gcc/g++ compilers based on POSIX thread model, i.e. compilers that were built with the option -...
Advice
0
votes
2
replies
57
views
Is it possible to use Static_Predicate with a record type?
I wanted to define a record type with a Static_Predicate:
-- irregular_matrices.ads
generic
type Element_Type is private;
package Irregular_Matrices is
subtype Index_Type is Positive;
...
3
votes
2
answers
130
views
How to properly constrain two-dimensional array types to be square in Ada?
I'm trying to create a package of generic adjacency matrices to define graphs, and the first goal is to define a static version based on two-dimensional array:
with Ada.Containers.Vectors;
generic
...
0
votes
2
answers
66
views
Is there a way to set Tabulation width in Ada?
I'm trying to get the hang of the Ada.Text_IO package, and it has many differences with IO of C.
One of them differences is how Get treats control characters and Horizontal or Character Tabulation ...
0
votes
1
answer
63
views
What is "freezing" and how to declare a vector of variant record type?
I've written the next piece of code in order to declare a vector of lexical elements:
type Lexical_Element_Kind
is (
Delimiter, -- & ' ( ) * + , - . / : ; < = > |
-- => .. ...
3
votes
2
answers
135
views
How to deal with incompatibility of similar instances of generic packages defined in different translation units in Ada?
I've created a generic package called Generic_Functions which must be instantiated in similar fashion to the standard Ada.Numerics.Generic_Real_Arrays and has next specification:
with Ada.Numerics....
1
vote
4
answers
179
views
In Ada 2022, what is the unit for string length?
I cannot find an answerin the reference manual, nor in the sections on strings in the AdaCore tutorials. Is the unit bytes (doubtful for bounded or unbounded strings), code units (pretty sure no), ...
1
vote
1
answer
99
views
How does the use of scalar types or subtypes simplify the logic of an Ada subprogram while also clarifying programmer intent?
What are the differences in efficiency when using a scalar subtype rather than precondition and postcondition aspect clauses?
There are several ways to evaluate efficiency. One is code terseness—using ...
0
votes
3
answers
120
views
Is there a known solution for converting IEEE Float values to Hexadecimal in Ada without using the IEEE package?
I do not have the ability to update our Ada compiler set so include the IEEE packages. Is there a way to convert a Float into a Hexadecimal integer? For instance, a Float value of 1.5 as input should ...
3
votes
1
answer
79
views
How to install gnatcheck on ubuntu
After building a docker container with:
add-apt-repository ppa:ubuntu-toolchain-r/test
apt-get update
apt-get install -y gnat asis-programs
I can make fine: gnatmake hello.adb, but when I try to run ...
0
votes
1
answer
104
views
"loadImageSVG" linker error when building with Ada Raylib
Hope you an help me, I am attempting to get into simple game development using Ada and the Raylib Ada binding. So far so good, I set everything up through Alire Package Manager, got VS Code to find ...
0
votes
1
answer
146
views
how to link c file in Ada with gnatmake?
good, I'll get straight to the point. I have a program that needs to run tasks. These three tasks communicate with each other and call C functions for their needs. I wrote functions that call C ...
-1
votes
1
answer
199
views
How to create an executable Ada file with gnatmake
I have an Ada program that calls a C function. I have the C object file. I wrote an small test to see if it works. When I run:
$ gnatmake main.adb -largs cfile.o -lpthread
apparently there's no error ...
1
vote
3
answers
146
views
Constraints not checked when calling ADA code from C++ Code
I am working through a light example of calling Ada code from C++ code. I was able to induce a buffer overflow and read data past a buffer using the following code:
main.cpp
extern "C" {
...
3
votes
2
answers
173
views
Better way to organize build (GPR... or gnatmake) [closed]
I'm changing the compiler of a medium-sized codebase, mostly Ada (with some C & C++ modules), from ObjectAda (PTC) to Gnat.
The product consists of ~100 Windows executables and ~20 dlls (~1500 Ada ...
0
votes
1
answer
86
views
How to change output format in Ada logging
The default format for Util.Log is
[date] level - module - : message
So something like
[2025-03-04 08:29:28] INFO - main - : Crypt : dc7e84bfda79164b7ecd8486985d3860
I'd like to change
the level ...
0
votes
2
answers
56
views
User defined log filename in Ada
The following compiles
with Util.Log.Loggers;
package body LogTest is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create("./abc.log");
...
end LogTest;
The problem is ...
0
votes
0
answers
74
views
add another packages into a ada project
here i've two projects (project1 and project2) on my machine (debian 12 if it help) which are into two different directories. the first, project1 is into All_My_Projects/App_Projects/Project1 and the ...
2
votes
3
answers
255
views
Print a hex number with leading zeros in Ada
Is there a simple way of printing hexadecimal numbers with leading zeros in Ada? The following will print a number with leading zeros in hex but it is a bit convoluted.
with Interfaces;
with Ada....
3
votes
0
answers
94
views
Howto Round an Ada Fixed point Type To Decimal precision?
type Number_Type is delta 0.000_1 digits 18;
--------------------------------------------------------------
-- Round Number To Decimal 0
------------------------------------------------------...
1
vote
1
answer
223
views
GNAT Community Edition on Debian Bookworm 12.2
I have installed gnat-2021-20210519-x86_64-linux-bin from
https://www.adacore.com/download
When I tried to build simple project with gprbuild tst.gpr, linking failed with messages
Link
[link] ...
1
vote
2
answers
75
views
Is the Put procedure altering the value of my variable?
I'm learning Ada, and I wrote a function to calculate the factorial of a number and a simple program to call it. However, depending on the way I format the display of the result, my variable gets a ...
0
votes
2
answers
78
views
How to destroy the button from a GtkAda widget?
"MISSING A callback handler is also needed for the X button when you close the dialog otherwise it never closes and remains in the background." I tried the attached code to solve this, but ...
1
vote
1
answer
80
views
How to retrieve the name of the file from a GtkAda widget?
The attached code compile & runs.
-I should want to retrieve & manipulate the file name of a GtkAda widget.
I do see it's possible when we manage directly the object (How to create a file ...
0
votes
1
answer
139
views
Use switches in the .gpr file for Ada program in community compiler 25.0w
I am compiling a program with "Build & debug" and get the following error message:
[2024-12-12 11:24:45] Could not determine the project for file: D:\ada\project\Sudoku\Sudoku_main.gpr
[...
0
votes
2
answers
124
views
Does GNATCOLL.traces exist?
Whenever I look up logging in Ada, one of the recommendations is GNATCOLL.Traces. I can see the documentation for it but there is no code.
If I try something like
with GNATCOLL.Traces;
I get an ...
5
votes
1
answer
134
views
Cannot use `'First` and `'Last` on unbounded strings
When trying to get the first or last index of an unbounded string, as shown in this program
with Ada.Strings; use Ada.Strings; -- for `Backward`
with Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada....
2
votes
1
answer
95
views
Speeding up alr build with gtk
Is there a way of speeding up an alr build with gtk? Say I start a new project.
alr init --bin a98xml
alr with gtk
That is simple enough.
alr build
This takes about 4 minutes. We only have to do ...
0
votes
1
answer
89
views
How to get the color from GtkAda?
the attached code compile & runs.
$ ./xml_code
Loading of XML is OK
(xml_code:31196): Gtk-CRITICAL **: 22:24:59.048: gtk_color_chooser_get_rgba: assertion 'GTK_IS_COLOR_CHOOSER (chooser)' failed
...
0
votes
0
answers
181
views
gprbuild: Shared libraries between multiple projects
I have a couple of executables that I want to be able to use the same libraries. After building, I want the tree to look like this (simplified example):
Root
|--Prog1
| |--src
| |--obj
| |--Prog1....
0
votes
1
answer
130
views
How to run a pre build script in gnat project file?
I have a mixed C++ and Ada project.
A GPRbuild project is used to build it and there is no makefile.
There is a script which creates an H file with constants such as build host, username and git ...
0
votes
1
answer
96
views
How do I implement putchar in C to support RTS?
I'm implementing a minimal Ada RTS for the esp32s3 SoC. Currently, I am stuck with an error that's proving resistant to every solution I've thrown at it. It claims putchar is undefined:
Link
[link] ...
0
votes
1
answer
112
views
How to switch off -gnatyt in alr
I've just installed alr on Linux. Haven't used ada for about 10 years and found that gnat community is no longer supported. Entered the following program
with Ada.Text_IO;
procedure A02hello is
...
0
votes
0
answers
106
views
Change background color with gtkada css
Hi everyone and sorry again for the inconvenience but since then I have created a window with gtkada to which I want to change the color of the background with css, but this is where things get ...
2
votes
1
answer
124
views
Dynamic Dispatching with Generic Packages in Ada
I am having trouble getting dynamic dispatching to work with Ada generics. Is there an elegant way (something better than conditions such as if X in A then ...) to have the generic Print procedure in ...
1
vote
1
answer
202
views
Adding wide character support breaks ncurses menu
I'm currently trying to create an ada program (this will be relevante later on) with a basic TUI.
To do so, I'm using ncurses, and more specifically, I'm interfacing with C as the ada bindings, ...
0
votes
0
answers
117
views
how to install gtkada on linux
i can't to install gtkada on my Linux PC. I tried look at the adacore's docs but I can't to understand. please someone can help me to install gtkada.i'm really blocked.
after to have download and ...
0
votes
0
answers
65
views
Adding hashmap elements to an unbounded_wide_string doesn't add it to the end
I'm not too sure what I did, but I accidentally solved my issue?
While I was working on integrating comma support I decided to extract from the below function the conditions and put it in another one.
...
2
votes
2
answers
142
views
How do I defer the full definition of a type?
Assume I have the following subprogram declared in the specification.
package Waiter is
type Time_Span is ????; -- Time_Span definition TBD...
procedure Wait (Period : Time_Span);
end Waiter;
...
2
votes
1
answer
141
views
Ada integer text guess error, how to fix?
So I was creating a guessing game for Ada but yeah it doesn't run. The error is in Line 25.
It says
guessing_game.adb:25:26: error: no candidate interpretations match the actuals:
with Ada.Text_IO;
...
2
votes
2
answers
294
views
Range check failed when using reduction expression in Ada
I tried to convert the array concatenation in function A to the new Ada 2022 reduction expression (see function B), but I get a range check failed error. What am I doing wrong?
with Ada.Text_IO;
...
2
votes
2
answers
159
views
How to iterate over a range with a custom step?
How can I iterate over a range in Ada with a custom step ?
For I in Integer'Range
loop
-- do something every 10 steps
end loop;
Can I define a subtype with specific step ?
1
vote
1
answer
106
views
Build the whitakers-words dictionary with Alire
First of all I want to apologize for something wrong I will say, I'm new to Ada and Alire.
I am trying to use the whitakers-words dictionary (https://github.com/mk270/whitakers-words) for a personal ...
3
votes
4
answers
504
views
How can I add an additional compiler option in an Alire .toml file?
For cross-compilation I need to specify the MCU type as a option to the Ada, C and theoretically C++ compiler.
How can I do that and in a way that it is also applied when building the dependencies?
At ...
5
votes
2
answers
188
views
Array of single bits in ada?
If I wrote
type u1 is range 0 .. 1;
type Index is range 0 .. 499999;
type U1Array is array(Index) of u1;
can I assume, that this will be a bit vector, which is packing the single u1 instances ...
3
votes
2
answers
211
views
Alias usage in Ada language
Package pack1 is
Type int_acc_type is access all integer;
End pack1;
--Local procedure
with pack1;
Procedure main is
Int_acc : pack1.int_acc_type;
Int_var : aliased integer;
Begin
Int_acc ...
0
votes
1
answer
209
views
How to avoid circular dependencies in Ada?
I have two packages called Passenger and Booking. They have a one to many relationship. I encountered a circular dependency error when I tried to do with in both of their files. I then tried limited ...
2
votes
2
answers
146
views
Subtype of string containing only hex characters in Ada
How can I define a subtype of String that allows only hex characters to be used? Here is my attempt, but I fail at the subtype definition:
subtype Hex_Character is Character
with Static_Predicate =&...
0
votes
0
answers
140
views
How to build SSL enabled for Ada Web Server?
I'm trying to get HTTPS requests working with Ada Web Server (AWS) found at https://github.com/AdaCore/aws/tree/master
I'm on Windows 11 and I don't understand how to make a build of the library and ...
1
vote
0
answers
232
views
How to do HTTPS requests in Ada Web Server?
I am trying to make HTTPS Get requests to websites in Ada web server. I can currently do HTTP requests without issues but HTTPS fails - possibly due to SSL Certificates. I am only using the client ...