❌ About FreshRSS

Normal view

There are new articles available, click to refresh the page.
Today — 30 November 2023News from the Ada programming language world

How to use Ada testing frameworks in VS Code (or with some other test runner)?

I got Alire based build & debug working in VS Code (on Windows), but how to configure AUnit (or any other Ada testing framework) based testing in VS Code? Alternatively, I am okay with other testing systems that would provide fluent setup and coding experience. Link to a complete example project with working test setup would be nice.

I am looking for a smooth experience in exploring my own code and libraries using tests, so being able to run a specific test and subset of tests would be very useful.


submitted by /u/anyfreename123
[link] [comments]
Yesterday — 29 November 2023News from the Ada programming language world

Generating Ada bindings for C headers (Gem #59) doesn't work any more

When I used this method a few years ago, with Ada from the Ubuntu repository, it worked fine. Now, with my installation from Adacore, not so anymore.

The method consists of 2 commands (time.h as example)

  1. g++ -c -fdump-ada-spec -C /usr/include/time.h
  2. gcc -c -gnat05 *.ads

While the first command executes without any problem, the second one returns:

gcc: fatal error: cannot execute ‘gnat1’: execvp: No such file or directory

It doesn't depend on the -gnat05 option. There is indeed no gnat1 in the bin directory of the Ada installation. Mine is version 2021. I am reluctant to install the GNU version in parallel, I might mix up things.

Any other idea?

Before yesterdayNews from the Ada programming language world

Type not visible in child package

I have the following parent package which defines several types


package AES is    
    type Byte is range 0..2**8  - 1;
    type Input_Buffer is array(Natural range <>) of Byte;
    type Output_Buffer is array(Natural range <>) of Byte;
    type Key is array(Natural range <>) of Byte;
    subtype AES_128_Key is Key(0..127);
    subtype AES_192_Key is Key(0..191);
    subtype AES_256_Key is Key(0..255);
    type Operation is (Encrypt, Decrypt);

    function AES_CBC_128(Input: Input_Buffer; Key: AES_128_Key; Op: Operation) return Output_Buffer;
    function AES_CBC_192(Input: Input_Buffer; Key: AES_192_Key; Op: Operation) return Output_Buffer;
    function AES_CBC_256(Input: Input_Buffer; Key: AES_256_Key; Op: Operation) return Output_Buffer;

    type Word is range 0..2**32 - 1;
    type State is array(0..3, 0..3) of Byte;
    type States is array(Natural range <>) of State;
    type Round_Key is array(0..16) of Byte;
    type Key_Schedule is array(Natural range <>) of Round_Key;
end AES;


with AES.AES_Cipher; use AES.AES_Cipher;
with AES.AES_Inv_Cipher; use AES.AES_Inv_Cipher;

package body AES is

-- other definitions

function AES_Common(St: State; K: Key; Op: Operation) return State is
    Schedule: Key_Schedule := Key_Expansion(K);
    return (case Op is
        when Encrypt => Cipher(St, Schedule),
        when Decrypt => Inv_Cipher(St, Schedule)
end AES_Common;

-- more definitions

end AES;

and then two child packages (aes-aes_inv_cipher is very similar to aes-aes_cipher so has been omitted)


package AES.AES_Cipher is
    function Cipher(St: State; Schedule: Key_Schedule) return State;
end AES.AES_Cipher;


package body AES.AES_Cipher is

function Cipher(St: State; Schedule: Key_Schedule) return State is
    return St;
end Cipher;

end AES.AES_Cipher;

These are called from main.adb

with AES; use AES;

procedure Main is
    Input: Input_Buffer(0..35) := (others => Byte(44));
    K: AES_128_Key := (others => Byte(55));
    Output: Output_Buffer(0..35);
    Output := AES_CBC_128(Input, K, Encrypt);
end Main;

This does not compile with the following error

aes-aes_cipher.ads:2:25: error: "State" is not visible (more references follow)
aes-aes_cipher.ads:2:25: error: non-visible (private) declaration at aes.ads:17
aes-aes_cipher.ads:2:42: error: "Key_Schedule" is not visible (more references follow)
aes-aes_cipher.ads:2:42: error: non-visible (private) declaration at aes.ads:20

I thought because aes-aes_cipher is a child package of aes it could access the private definitions in aes.ads but the error suggests otherwise. If this is not possible, how can I restructure the program so it works as expected? Removing private fixes it but those types should be private outside the package. I am using gnatmake version 13.2.0 on Windows.

Managing Multiple Projects

How do you go about organizing a bunch of different projects? I have several Ada (and other) projects, some of which depend on other projects and am looking for suggestions of how best to organize them.

My current approach is to have one "root" project that provides a top level package namespace (bbs) for all of my other projects. Thus, for example, my tiny Lisp interpreter is in the package bbs.lisp, with sub packages off of that. Each project is also in its own GitHub repository. Most projects also include some testing or use code that is not shared with other projects, and this code is outside of the bbs package hierarchy. Does this sound like a sensible approach? What is your approach?

submitted by /u/BrentSeidel
[link] [comments]

Latitude Looking For GNC Engineer (Ada experience a plus) to Work In Reims,France

Hi, after reading about Latitude adopting Ada and SPARK, I browsed their website and noticed the following job opening that mentions experience in “Ada would be a plus.” I hope this is a good potential for someone in the Ada community.


submitted by /u/micronian2
[link] [comments]

AEiC 2024 - Ada-Europe conference - 2nd Call for Contributions

The 28th Ada-Europe International Conference on Reliable Software Technologies (AEiC 2024) will take place in Barcelona, Spain from 11 to 14 June, and comprises different tracks and co-located events.

Submission deadlines: 15 January for journal track papers; 26 February for industrial track and work-in-progress track papers, tutorial and workshop proposals. Submit early: tutorial/workshop proposals will be evaluated ASAP, with decisions from 1 January 2024!

More information on the conference site, including an extensive list of topics, and details on the call for contributions for the various tracks.


#AEiC2024 #AdaEurope #AdaProgramming

submitted by /u/Dirk042
[link] [comments]

How to Overload the Subscript/Subprogram Call Operator in Ada

We all know and love Ada.Containers.Vectors. Here's an example of its usage:

with Ada.Text_IO;
with Ada.Containers.Vectors;

procedure Example is
   use Ada.Text_IO;

   package Vectors_Integer is new Ada.Containers.Vectors (Natural, Integer);
   use Vectors_Integer;

   My_Vec : Vector := 1 & 2 & 3;
   Put_Line (Integer'Image (My_Vec (0)));
end Example;

My question is simple: how does My_Vec (0) work, and how can I recreate this behavior in a type of my own?

I have been searching the internet for a while but I can't find to seem any explanation for how this expression works. The subscript operator, which uses the same syntax as the function call operator, cannot be overloaded using the normal syntax for operator overloading. I've read the package specification for Ada.Containers.Vectors, and there doesn't seem to be any explicit means through which Vector overloads this operator. I had guessed that the Element function might have something to do with it, but have been unable to use it to define a type of my own that replicates Vector's behavior. I'm at a complete loss on how to overload the subscript operator, even though it is clear that it is possible.

ChatGPT says there is a pragma Finalize_Procedure - is that correct?

I was playing around with ChatGPT producing code it produced...


 -- Finalization procedure procedure Finalize is begin -- Perform cleanup or finalization actions here Resource := 0; -- Reset the resource when the object goes out of scope end Finalize; pragma Finalize_Procedure (Finalize); 

A quick search found no reference to this pragma, so is ChatGPT imagining this?

submitted by /u/SirDale
[link] [comments]

Blinken Lights Project

I am now able to toggle in a bootstrap and getting CP/M running on Pi-Mainframe project with my 8080 simulator. The repositories have been updated. Some more work is needed to polish things a bit, but you can see the lights blink for the address and data values.

The drawback for this being a practical simulation is the overhead of the I2C bus. From the speed at which the lights blink, the instruction rate seems to be about 200 instructions per second. It certainly slows the terminal output.

submitted by /u/BrentSeidel
[link] [comments]

Ravenscar on Multicore processor

My Googling is failing.

I'm trying to create a Ravenscar project for a RP2040 that has two cores.
The project has several tasks, protected objects, and interrupt handler procedures encased in protected objects.

I can statically set the CPU of a task with 'with CPU => N'. Can I do the same with a protected object? Or can I only do that for procedures in a protected object? Or does the protected procedure inherit the CPU affinity of the calling task? If that's the case, what happens for an interrupt?

Thanks for your help.

submitted by /u/NedFlanders_2800
[link] [comments]

Ada design by contracts critical software

I have a question related to applying contracts in a critical environment.

Imagine I have the following function to divide:

function div (dividend, divisor : Float) return Float
with Pre => divisor /= 0;

Well, for me the pre-condition is part of the signature of the function and every client must be aware of the contract, if a client pass a zero to the divisor argument is its fault bacause he is violating the contract and thus the function will fail. In testing, with pre-conditions activated, the code will fail showing a contract violation and, in production with pre-conditions deactivated, would fail raising a constraint.

As a constraint error is not acceptable in a critical environment, this is what the client is requiring me for the implementation, to call a module that manages inconsistencies:

function div (dividend, divisor : Float) return Float is
  if divisor = 0 then
    InconsistencyManager.inconsistency ("Some Log"); --It firstly logs a message and then does an infinite loop

  return dividend / divisor; --If everything is ok, return the division
end div;

For me this side effect for a function its quite weird, and for me violating a contract is like passing the wrong type to a subprogram, the difference is that this kind of error is caught at compilation time and the contract violation, if there aren't enough tests, could stop the execution of the program when is already installed.

Do you really has to protect against human stupidity like this? Do you really has to penalize the function execution making always that question?