gcc compatability question
Can someone clarify the level of gcc compatability provided by the Sun Linux C++ compiler? Can we link objects compiled with both compilers into a single library? Can we mix libraries compiled with both compilers in a single application?
I tried to find docs on this but failed - if there is such documentation I'd appreciate a pointer.
Thanks,
Martin
[378 byte] By [
martinwatt] at [2007-11-26 9:25:12]

# 1
Martin,
I think the word you're looking for is "ABI" - Application Binary Interface. On x86 side, there are two standard ABIs - i386 ABI for 32 bit platforms and AMD64 ABI for 64 bit platforms (http://www.x86-64.org/documentation). Sun compilers obey these ABIs. To my understanding, so goes gcc but not g++, which has its own ABI. So I guess that Sun compilers are binary-compatible with gcc but not with g++.
Thanks,
Boris
# 2
Expanding on Boris's answer:
Binaries created from C source code by gcc and Sun C usually can be freely intermixed. In particular, programs created by Sun C on Linux link with the system libraries, which were created by gcc.
You can mix C and C++ binaries in the same program, although you usually need to use the C++ compiler driver (CC or g++) to link the final program.
Since Sun C and gcc C binaries can be mixed, you can also link both kinds of binaries into code compiled by g++ or Sun C++.
I general, no two C++ compilers generate the same ABI for C++ code. You normally cannot mix binaries from different C++ compilers. For a discussion of C++ ABI issues, see my paper here:
http://developers.sun.com/prodtech/cc/articles/CC_abi/CC_abi_content.html
We are working toward generating the g++ ABI as an option using Sun C++, so that you would be able to mix binaries from g++ and SUN C++ in the same program. We aren't there yet, but watch this space for announcement, probably next year.