Re:A Special Kind of Hell: intmax_t in C and C++
by pjmlp on Sunday December 06, 2020 @02:01AM
(#25321722)
That is an UNIX problem, not every OS uses C as the OS ABI, e.g. Android, Windows, IBM i, z/OS, ...
Also given the target domain of C, the standard also must take into account possible free standing deployments, where an OS doesn't even come into play.
Re:A Special Kind of Hell: intmax_t in C and C++
by colejohnson66 on Sunday December 06, 2020 @09:04PM
(#25328674)
I thought Windows does use C as an ABI?
Re:A Special Kind of Hell: intmax_t in C and C++
by pjmlp on Monday December 07, 2020 @07:35AM
(#25331544)
Nope, the calling conventions are selectable, originally on the 16 bit days actually used Pascal calling convention, then with age there are several APIs whose public API is only available as either COM, .NET or both, regardless how the interface with the kernel is done.
When I ran into similar problems trying to distribute a binary for Linux users, I thought "Screw it, I'll just statically link everything." But the older statically linked C libraries would crash on newer kernels, and the newer static C libraries would refuse to run on older kernels. (Or do I have that backwards? Anyway, I ended up concluding that Linux doesn't really have a stable ABI.)
Now, if you think "operating system" == "kernel", then, yes this is a language problem. And yes, people who write in x86 assembly and directly invoke the Linux kernel don't have all of these worries. They have much more manageable backwards compatibility issues. But for most of us, "programming to Linux" means using the APIs defined in man pages.
Perhaps the actual "OS API" should be more completely divorced from C library issues. The kernel should define its own contract in some kind of IDL from which one can generate APIs for any language (including all of the variants of C that differ by implementation choices). Yes, it should map to C without any impedance mismatch, and the C folks can deal with how exactly it maps to different implementations of C, but other language runtimes shouldn't have to go through C and re-live all its problems.