compile gcc and library

Ian Lance Taylor iant@google.com
Thu May 24 19:17:00 GMT 2012


Xin Tong <xerox.time.tech@gmail.com> writes:

>> In general, yes.  For pure C code, yes.  For C++ code, some caveats may
>> apply.
>>
>
> This is the reason why gcc contains a c++ library, but no need for C
> library ?

A C library inherently has lots of system dependencies, like how to do
I/O on the system.  It's easier to maintain that separately from the
compiler.

A C++ library does not have those dependencies, because it can simply
use the facilities of the C library.  Also, a C++ library has some close
ties to the compiler, e.g., in how exceptions are implemented and
details of things like __is_pod.

Also and probably more importantly, historically GCC was developed on
systems that have C libraries but don't have C++ libraries.  So GCC
always needed to provide a C++ library, but rarely needed to provide a C
one.

> what kind of caveats , like different mangling styles ?

That is one, yes.  In general the C++ ABI is much more complex and
subtle than the C ABI, and there is a correspondingly higher chance of
some sort of breakage.  That said, it usually does work fine.

Ian



More information about the Gcc-help mailing list