[comp.sys.mac.programmer] How smart is THINK C?

perry@key.COM (Perry The Cynic) (05/20/89)

Hello! I have a question about THINK (aka Lightspeed) C, Version 3.

In the manual they tell me proudly that they have a 'smart linker'. It uses
only those parts that are actually used (called?). Great.

So, I put a few functions into a source file, call only one of them from
the main program, and look at the result. Nope, all the code is there,
even the totally unused functions.

What is the granularity of 'smart linking'? One function? One source file?
One code segment? And how does that apply to libraries (both MacTraps and
project files used as libraries)?

Is 'smart linking' supposed to help me with my own code, or does it exist only
to avoid including all of MacTraps into every program? What's the scoop?
Inquiring mind wants to know. Thanks
  -- perry
-- 
------------------------------------------------------------------------
Perry The Cynic (Peter Kiehtreiber)		     perry@arkon.key.com
** What good signature isn't taken yet? **	   ...!pacbell!key!perry

chuq@Apple.COM (Chuq Von Rospach) (05/20/89)

>So, I put a few functions into a source file, call only one of them from
>the main program, and look at the result. Nope, all the code is there,
>even the totally unused functions.

>What is the granularity of 'smart linking'? One function? One source file?

In your source file, the granularity is the file. (which makes sense,
actually. If you create an arbitrary CODE resource it may not be possible
for the linker to know whether the code is in use or not).

If you take that same source file and make it a library, though, when you
link it in to your project and build an application only the routines needed
will be in there, since the ambiguity isn't there.


Chuq Von Rospach      =|=     Editor,OtherRealms     =|=     Member SFWA/ASFA
         chuq@apple.com   =|=  CI$: 73317,635  =|=  AppleLink: CHUQ
      [This is myself speaking. No company can control my thoughts.]

This is....The Voice....of USENET....in special English. 1300UTC on 11525. 

siegel@endor.harvard.edu (Rich Siegel) (05/20/89)

In article <826@key.COM> perry@arkon.key.COM (Perry The Cynic) writes:

	[Asks about smart linking]

	In LightspeedC, the smart-linking is granular to one source or
library file. This means that ifan entry in a project is a project
consisting of multiple files (such as MacTraps), only those library
units that are referenced are linked in a build time.

	It's noticed most for MacTraps, stdio, and other large
standard libraries where not everything is used (although, stdio
is so spaghetti-ized that most everything gets dragged in anyway.:-( ).

	In Lightspeed Pascal, the situation is much the same, except that
libraries that are built from multi-file projects are smart-linked
down to their component files, in much the same manner as C projects
described above.

		--Rich


~~~~~~~~~~~~~~~
 Rich Siegel
 Staff Software Developer
 Symantec Corporation, Language Products Group
 Internet: siegel@endor.harvard.edu
 UUCP: ..harvard!endor!siegel

 "She told me to make myself comfortable, so I pulled down my pants
 and sat in the pudding." -Emo Phillips
~~~~~~~~~~~~~~~