Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> First of all, it is the OS ABI, in operating systems that happened to be written in C.

It may be per-OS (I wouldn't try linking Linux and NT object files even if they were both compiled from C by GCC with matching versions and everything), but enough details come from C that I think it's fair to call it a C ABI. Like, I can write unix software in pascal, but in order to write to stdout that code is gonna have to convert pascal strings into C strings. OTOH, pascal binaries using pascal libraries can use pascal semantics even on an OS that uses C ABIs.



Strings is the easy part.

Try to link two binary libraries in Linux, both compiled with GCC, while not using exactly the same compiler flags, or the same data padding, for example things like structures.

Since committee people can explain it even better,

"To Save C, We Must Save ABI"

https://thephd.dev/to-save-c-we-must-save-abi-fixing-c-funct...


Sorry, this is nonsense. Binaries link just fine on Linux. If you use a compiler flag that changes the ABI, then you are on your own, of course, but the GCC docu makes it very clear which specific flags those are. There is some corner cases with problems where you get problems if you use different compilers, e.g. atomic alignment (by adopting the broken C++ design into C) and some other corner cases where compilers did things slightly different.


> e.g. atomic alignment (by adopting the broken C++ design into C)

I would like to learn more about that. Do you mean this:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65146


Things like this resulting in differnt alignment between Clang and GCC on x86_64 for _Atomic struct { char a[3]; }; See: https://godbolt.org/z/v5hsjhzj9

The problem is that in C++ these atomics are library types, but in C they are built-in types which should have a clearly specified ABI. But the goal was to make them compatibility with C++ library types, which is a rather stupid idea, which pulls in even more problems.


Assuming you have control over all binaries.

Exactly because one gets issues with multiple compilers is yet another prof why there isn't such thing as official C ABI.


There official platform ABIs. There are not called C ABIs though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: