Is the ABI part of the C standard?

It seems to me that C libraries almost never have problems mixing libraries compiled with different versions or (sometimes) even with different compilers, and that many languages ​​seem to be able to interact with C libraries directly or with minimal effort.

Is this all because ABI is standard?

+3


source to share


4 answers


The ABI is defined by the operating system and / or toolchain and is not defined by the standard. It defines, for example, how parameters are passed to a function call. What is the layout of the stack frame or how the system calls are made.



The reason most languages ​​can interoperate with C libraries is most likely because most operating systems are (more or less) written in C, exposing C libraries as APIs and defining an ABI based on that. And if a library written in a particular language wants to interact with a particular OS, it must be able to bind the ABI of that OS.

+1


source


ABIs are not encoded in the language standard. You can get a copy of any of the standard C drafts to see for yourself.



And there is a good reason why ABIs are not in the standard. The standard cannot in any way provide for all the hardware and OS for which C compilers can be implemented.

+7


source


The ABI is definitely not standard. At least not in the C standard. Every operating system or toolchain defines these things, but the language itself does not. Try running a Windows program on a Linux machine for example.

+2


source


The ABI is not part of the C standard. However, efforts have been made to standardize the ABI. Quoting from " Linux System Programming :

Although there have been several attempts at defining a single ABI for a given archive (in particular for i386 on Unix systems), the effort has not met with much success. Instead, Linux operating systems are included, usually defining their own ABIs, but they see fit.

+1


source







All Articles