Mail Archives: djgpp/1997/10/28/19:00:20
Brett Porter wrote in article <199710270603 DOT RAA16492 AT rabble DOT uow DOT edu DOT au>...
>This issue was not addressed in the FAQ, and a quick browse of the mail
>archives yielded two different answers in posts of people I haven't seen on
>this group since I've been here.
>So I would like a definitive answer from someone who knows 100% that it is
>the truth, the whole truth and nothing but the truth (so help me God).
>Anyway, the scenario is...
>I am writing two programs simultaneously that share some classes, so I link
>the files with just those classes to both. Some of the functions in these
>classes are used in both programs, some only in one (ok, maybe this isn't
>example of great design, but I'm not a C++ purist, so I don't really care)
>Now, will _all_ of the functions be linked into _both_ of the programs, or
>only the ones used? If they all are, is there a way of making sure only the
>used ones are linked (eg conditional defines, or <cringe> only good
>I appreciate this help, and I'm _really sorry_ if the issue has already
>beaten to death (I couldn't really find it in the search with keyword
>'link'), but if I at least get a definite answer here, future searchers
>might have better luck.
>Thanks for your help.
>"Who here believes in telekenesis? Raise MY hand!"
>bporter AT rabble DOT uow DOT edu DOT au
> Humour, Programming, and more.
The linker links in the ENTIRE OBJECT file, even if just 1 of the
objects in it are needed. If you have class functions defined in a .O file,
and use that class, EVERYTHING in the object goes in. This is why each
function from the C library is seperate - so no unneeded code gets linked
in. The use of the word EXTERN is ok when delcaring variables (such as with
allegro) but if the variable is never used again, just the definition, then
it doesn't get linked. Hopefully, that answers your question.
- Raw text -