home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:19586 comp.lang.c++:19015
- Newsgroups: comp.lang.c,comp.lang.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: C/C++ Speed
- Message-ID: <1993Jan12.164147.18840@taumet.com>
- Organization: TauMetric Corporation
- References: <1ipsk5INNf5m@aludra.usc.edu> <dak.726696239@tabaqui> <1993Jan11.163852.19740@informix.com>
- Distribution: usa
- Date: Tue, 12 Jan 1993 16:41:47 GMT
- Lines: 31
-
- cshaver@informix.com (Craig Shaver) writes:
-
- >Who implements an intelligent C++ linker??? I was under the impression that
- >you get all the functionality in a class when you link, whether you use it
- >or not.
-
- Most C++ implementations use a linker which works like the linker for C;
- often it is the same linker. With typical implementations, a function
- is included in the executable if it is referenced (called or address
- taken), or if it is in the same module as something else which is referenced.
-
- If the C++ programmer puts all the class functions in one module, then
- any use of the class gets the code for all functions, but not necessarily
- otherwise. Class member functions may be divided up among different
- source modules just like ordinary functions.
-
- That is the situation in C++ for non-class functions, and for class member
- functions which are not "virtual".
-
- If a class has "virtual functions", their addresses are usually kept in
- a table which becomes part of the executable. This means that all the
- virtual functions are referenced by this table, and thus included in
- the program whether or not they are called. The C++ language does not
- require this implementation of virtual functions, but it is the usual case.
-
- The situation is comparable to a C programmer making a table of
- functions or a switch statement which might call any of several functions.
- The functions get linked into the program whether or not they are called.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
-