9 ms·
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
by onox 5y ago
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 https://github.com/onox/inotify-ada
[2] https://github.com/onox/evdev-ada https://github.com/onox/evdev-ada
- touisteur 5y agoCan attest to that. C++ is also OK. You still have to write the 'binding' but the compiler can generate a good part for you. Then you can 'hide' all the C-like things (like 'a pointer is an address', 'an enumerated type is an integer', 'you have to call our free() when you're done'...) behind opaque types, controlled types, etc. As a simple example you can lookup what the compiler generates as a low-level binding [0] that is wrapped in a higher level API [1]. BTW you can also bind Ada to Java (although support is a bit limited I know places where it's in prod). Don't remember if it's a commercial product or oss. And for the python people, my company financed a first version of ada-py-bind, inspired by the great pybind11. Still a lot of code to write (or generate) but it works fine. Thanks onox for those two links! [0] https://github.com/persan/zeromq-Ada/blob/651ca44cce831c2d717338eab65a60fbfca7ec44/src/gen/zmq-low_level.ads#L601 https://github.com/persan/zeromq-Ada/blob/651ca44cce831c2d71... [1] https://github.com/persan/zeromq-Ada/blob/651ca44cce831c2d717338eab65a60fbfca7ec44/src/zmq-sockets.adb#L218 https://github.com/persan/zeromq-Ada/blob/651ca44cce831c2d71...