4 ms·
And how many of those are defined in terms of the underlying C ABI? For example, WinRT - used by Windows/UWP - can be expressed entirely in terms of C structs
by int_19h 8y ago
And how many of those are defined in terms of the underlying C ABI?
For example, WinRT - used by Windows/UWP - can be expressed entirely in terms of C structs and function pointers.
- pjmlp 8y agoBy exploiting how Windows C++ compilers layout VMT tables. Yet this is much less relevant in UWP, which allows for richer type system. Additionally the COM/UWP ABI requires type libraries for properly accessing the objects and marshaling.
- int_19h 8y agoCOM is a C ABI first and foremost - somewhere in MSDN, there's actually a page that exactly specifies vtable layout. It's not really surprising that it's C++-compatible, given that it's the most obvious way to do a vtable when you have just a single base class. But yes, of course, Win32 C++ implementations would maintain that compatibility - you could consider it the C++ bindings to COM, in a sense. And yes, WinRT does require its metadata for marshaling (COM doesn't - you can compile proxies/stubs from IDL). It does not require that for accessing objects, and there are many WinRT components which, in fact, cannot be marshaled at all. But all that doesn't make it any less of a C ABI - the metadata format is documented, and the standard WinRT APIs used to access it are themselves WinRT-compliant, and therefore the whole thing can be consumed from C, if painfully.
- pjmlp 8y agoThat is like telling anything can be consumed from Assembly, thus it has an Assembly ABI, even if painful.
- int_19h 8y agoAny ABI is assembly ABI, by definition, since you are not constrained at all in assembly. Similarly, the definition of a C ABI is "ABI that can be expressed in C terms" (not "ABI that is easy to code against in C") - i.e. an ABI that any language with C FFI can use. That last part is what makes this categorization useful. And it has some significant implications beyond "assembly ABI" - for example, C doesn't have guaranteed optimized tailcalls, and therefore any such ABI can't provide such a guarantee, either. Or - C doesn't have exceptions, and so COM and WinRT have to use error signalling mechanisms that are expressible in C (HRESULTs and thread-local error description objects). Or take async - WinRT offers CPS-style futures via IAsyncResult, and because that's just a WinRT interface, any language that can do C FFI can do WinRT async (unlike fibers, goroutines etc, which require intrinsic support).