Why RTOS + Ada?
Ada provides tasking. Why then use Ada with an RTOS like VxWorks?
13 posts - 7 participants
Ada provides tasking. Why then use Ada with an RTOS like VxWorks?
13 posts - 7 participants
Folks,
I started learning Ada about 2 weeks ago and these thick bindings to libusb is my first Ada project.
I can now neatly iterate over connected USB devices. I only added enough functionality to list USB devices but will add more in the near future.
Please spare a few minutes to review my code and let me know what Iβm doing wrong, what I should do differently, what can be improved, etc.
For example, Iβm not sure if I should collect all type definitions at the beginning of the package or intersperse them between function declarations.
2 posts - 2 participants
Is there a convention for naming types and variables?
For example, I have a type named Context
which means that I canβt name a variable below Context
. I could rename type to Context_Type
but then would need to add _Type
to the rest of the types in this library lest I be inconsistent.
Alternatively, I can name the variable Ctx
and leave the type as Context
(also Dev : Device
, Devices : Device_List
, etc.) which is the approach Iβm taking now.
What is the canonical Ada way? I much prefer to use full variable names (in Ada) as opposed to abbreviations. Iβm trying to follow the AdaCore naming approach as much is possible but it fails in the case above.
function Init (Context : out Context) return C.int with
Import => True, Convention => C, External_Name => "libusb_init";
And a follow-up example belowβ¦
I canβt have a Device_Descriptor
since thatβs a record type in my library. I decided to use the _Kind
suffix but Iβm not happy about it.
type Descriptor_Kind is
(Device_Descriptor_Kind,
Config_Descriptor_Kind,
String_Descriptor_Kind,
21 posts - 10 participants
GNATCOLL.Refcount
provides a procedure to run some code when the reference-counted element is released.
How do I implement this procedure?
Iβm clearly missing something because Release
is not visible as GNATCOLL.Refcount.Release
and this doesnβt work
type Context_Contents is new GNATCOLL.Refcount.Refcounted with record
Address : System.Address;
end record;
procedure Release is new GNATCOLL.Refcount.Release
(Self => Context_Contents);
and gives me
usb.ads:29:47: error: "Release" not declared in "Refcount"
4 posts - 3 participants
How do I find out what exceptions a procedure or function throws?
Is there a language construct like βthrowsβ in C++ or is it up to the developer to document this in comments?
Iβm wrapping a C library that returns a handle in an argument unless the error code returned is non-zero. I would rather not have users of my library check for null handles so I thought I would convert errors to Ada exceptions. Is this the way to go?
18 posts - 7 participants
Good day folks!
Is this canonical Ada formatting or is there a way to improve it in Visual Studio Code?
type Size is (Device, Config, Intface, Endpoint, Audio_Endpoint, HUB_NonVAR, SS_Endpoint_Companion, BOS, Capability); for Size use (Device => 18, Config => 9, Intface => 9, Endpoint => 7, Audio_Endpoint => 9, HUB_NonVAR => 7, SS_Endpoint_Companion => 6, BOS => 5, Capability => 3); for Size'Size use Interfaces.C.unsigned_char'Size;
Thanks, Joel
13 posts - 5 participants