Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
Take as an example the gnat.sockets package from upstream gcc:
https://github.com/gcc-mirror/gcc/blob/master/gcc/ada/libgna...
Compare with the same file from the GNAT 2021 CE install:
GNAT/2021/lib/gcc/x86_64-pc-linux-gnu/10.3.1/rts-native/adainclude/g-socket.ads
you will find there are a bunch of blank lines where the runtime exception was.
The C interoperability of Ada is very good, you can import/export functions and specify whether records (structs) and arrays must have a C convention. I use it often to access libc and Linux kernel functions/syscalls [1][2].
[1] https://github.com/onox/inotify-ada
* Is there a way to declare data layouts to have compatibility with C, similar to #[repr(C)] in rust?
Yes, and if you have a C header file, gcc can even translate most struct definitions for you. Here's an example of a "thin" binding generated that way: https://github.com/JeremyGrosser/notcursesada/blob/master/sr...
* Is there a way to catch C++ exceptions?
Yes. https://www.adacore.com/gems/gem-114-ada-and-c-exceptions
* Is there a way to catch C longjmps()?
By default, the GNAT runtime uses setjmp/longjmp to implement exceptions. I'm not sure how you'd connect that to a C library's setjmp though.
* Is there a way to have some kind of custom control over ABI issues, e.g. define custom FFIs to langauges with a different ABI? Or anything close to this? For that matter, does any language have something like this or does it not make sense?
ABIs are selected with the Convention aspect. Conventions are implementation defined and would require patches to the compiler to add new ones. GNAT currently supports Assembler, C, CPP, COBOL, and Fortran calling conventions.