logoalt Hacker News

Thoroughly Understanding C++ ABI (2024)

68 pointsby rramadasslast Sunday at 2:58 PM62 commentsview on HN

Comments

Dwedityesterday at 2:29 PM

C++ ABIs are why Win32 settled on things like COM to do cross-module passing of objects. Because nobody could agree on a standard, the COM standard enforced a very specific calling convention, and a very specific vtable layout for COM objects.

show 6 replies
rramadasslast Sunday at 3:09 PM

As always, read wikipedia and follow links as needed - https://en.wikipedia.org/wiki/Application_binary_interface

rramadasslast Monday at 2:59 AM

GNU libstdc++ "Dual ABI" issue - https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_a...

show 1 reply
jeffbeeyesterday at 3:44 PM

One nice thing to remember is for projects you control, you can dictate the ABI. There isn't a law enforcement bureau that will arrest you for passing parameters in whatever register suits you. You just have to imagine life differently than they did in the 70s when they dreamed up dynamic libraries for reasons that are largely no longer valid.

show 1 reply
jdw64yesterday at 2:35 PM

Does the C++ standard guarantee binary ABI? Isn't that something that compiler and library contributors handle separately? So I think the arguments you see online are more accurate—vendors are the ones maintaining it.

In other words, the ABI we rely on today isn't really part of the C+ standard—it's more like the Itnaium C++ ABI or the MSVC C++ ABI.

In the end, I think the ABI stays stable because of community conventions established by compiler vendors.

show 4 replies
mohamedkoubaayesterday at 3:08 PM

C++ famously has no ABI, it is the implementations of C++ that have ABIs. The reason the situation is so bad is that it's considered explicitly out of scope of the language (it targets an abstract machine).

show 1 reply