2 ms·
Would it be possible to create a binary library format that declares its own ABI? Has anyone done something like that in the recent past? Not like GObject decl
by nerdponx 4y ago
Would it be possible to create a binary library format that declares its own ABI? Has anyone done something like that in the recent past?
Not like GObject declaring the interface in a special comment (modulo typos). Something that's fully machine-parseable in any programming language and does not require access to the source code.
I mentioned C2FFI (https://github.com/rpav/c2ffi https://github.com/rpav/c2ffi) in another post in this thread. That's an extra "spec.json" file that you need to distribute along with your library, but maybe that's a whole lot easier and simpler than inventing a new library format. And it's JSON, which is human-readable, so it's relatively easy to debug.
- pavlov 4y agoMicrosoft COM? It’s the foundation for a lot of the Windows API and was explicitly designed to be usable from non-C languages.
- anfilt 4y agoCOM! Have you ever tried interacting without some automated tooling or language support! It's horrible and verbose. When it comes to setting up everything to interact with COM, I feel likely I would be more productive in assembly. Although at least a lot of it can be setup with automated tooling. Although the interface seems to also have a lot more overhead than a basic function call. I hardly would call it a better situation.
- account42 4y agoOf course it is possible. You see, we already have tools that have to deal with binaries and let tell you query value of variables or call functions. They're called debuggers and binaries usually can contain some extra information (either inside the binary or as an extra file) that provides these debuggers with information about the ABI (and more) so that they don't have do parse the source code themselves. All of the big C (and C++) compilers can generate this "debug information".