Date: Tue, 20 Oct 1998 18:22:03 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Primro cc: djgpp AT delorie DOT com Subject: Re: C++ versus C libs In-Reply-To: <362c9337.512419995@news.cis.yale.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com On Tue, 20 Oct 1998, Primro wrote: > Well, I know I phrased that very badly (reflecting a shaky > understanding of all this)... but what I was really asking was "where > are the functions referenced in the header file coming from." That is, > if I include stdio.h in a C++ file, do the functions I end up adding > to my program come from the gpp lib, or the gcc lib (libc). I assume > the gpp lib. Your assumption is wrong. The C++ libraries don't replace the standard C functions, they are in addition to them. When you link a C++ program, gxx instructs the linker to scan the C++ libraries first, then the C library. (Add -v to the gxx link command line, and you will see this yourself.) So even if you link a C++ program, functions declared on stdio.h and other C headers come from the usual libc.a. > And beneath that question, basically I am wondering if a C program can > use functions from my C++ lib file, and vice-versa---> or are they > somehow too different. C++ functions can (and do) use functions from libc.a, that is why all prototypes in the C headers are declared inside ``extern "C"'' block, just like the one you missed. But C programs cannot easily use C++ library functions since the actual name of the function visible to the linker is mangled to include some indication of its argument types (there can be several different C++ functions with the same name but different argument types--that's what polymorphism is all about). > Thanks, Eli- your quick response means I might make some progress > today. You are welcome.