4 ms·
> 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 the
by 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).