4 ms·
There is no "The C ABI"; it is determined entirely by implementors. ISO C does not define the term "ABI", nor does it define anything like it under a different
by kazinator 5y ago
There is no "The C ABI"; it is determined entirely by implementors. ISO C does not define the term "ABI", nor does it define anything like it under a different name.
Some platforms have a documented ABI across the board which covers all their APIs together with the principal compiler family.
Others, like Windows, have an ABI for some core system interfaces. Development tools can have different ABIs in their ecosystem.
The rest of the article seems to be the complaint that there are problems linking code from different compilers on Microsoft Windows*, which is completely unsurprising in the light of my above remark.
The fix is: don't mix code from different compilers on Windows without adding the calling convention declaration specifiers (an language extension) and ensuring these are in the header files that are mutually used.
- layer8 5y ago> The fix is: don't mix code from different compilers It’s more than that: individual compilers can’t evolve (for example change the size of intmax_t), and therefore certain desired ISO C features couldn’t be implemented, because that would break ABI compatibility with code compiled by earlier versions, which would prevent users from upgrading their compiler until all their dependencies have been upgraded, which (a) may never happen and/or (b) may be a newer version with other compatibility breaks. It may be okay in a everything-is-open-source-recompile-the-world setting, but in general it’s absolutely not practical.
- kazinator 5y ago> It may be okay in a everything-is-open-source-recompile-the-world setting That is mostly a myth, except maybe in some embedded situations. > individual compilers can’t evolve (for example change the size of intmax_t) Compilers can provide __my_intmax_t which is decoupled from the standard intmax_t. If there are system libraries and third party libraries using intmax_t, you don't want to change it; that isn't really a valid form of evolution. Long before 64 bit systems were common, compilers had local types like __int64_t. Programs could detect (or assume) their presence, and typedef them to something nicer. GCC has __int128_t on platforms where intmax_t is 64 bits.
- layer8 5y ago> Compilers can provide __my_intmax_t which is decoupled from the standard intmax_t. That either means breaking compatibility with existing sources (which have to be changed to use __my_intmax_t instead of intmax_t), or not conforming to the standard (if __my_intmax_t is now the one with the semantics of ISO C202x intmax_t). Compiler vendors want neither.
- kazinator 5y agoI think I'm not qualified here, since my 33 years of continuous and ongoing C experience prevent me from seeing the problem. I'm like a C doctor, whereas this is some naturopathic or chiropractic issue that is outside of my field. The patient just needs someone to acknowledge and understand their feelings of having a problem, and go through the motions of some treatment that is entirely justified by the patient believing in its efficacy and necessity.
- int_19h 5y agoThe whole point of intmax_t is that it's an integer type that's at least as large as any other integer type the implementation has. The utility of this is obvious: it lets you write generic code that can work with any integer type regardless of implementation. But it does mean that intmax_t either has to change every time an implementation adds a new integer type, or the implementation has to disregard the standard (and thus generic code is no longer generic).