-
To link or not to link
I got question on linking particularly in msvc6.
Lets say I have the winmain in the main.cpp ->main.obj
I have a foo class=>foo.obj
and
foobar class->foobar.obj
In main i only have an instance of foo class.
Basically I want to compile both classes but only link foo.obj.
So is there a way to tell the linker "Hey if theres no instances of class foobar, dont link it in"??
Thanks
-
No, not automatically. Why do you want to compile foobar if there are no instances?
-
I would have thought it'd be optimized out anyway if there's no instances.
-
Not necessarily. It depends on the linker and its settings. And some more stuff. In general, stuff from .libs gets included only when needed, stuff from .objs always.
Still, you could simply NOT compile the file...
-
That sort of optimization can only be done by the linker. For example there could be a bar.obj that uses the foobar class, in which case it should not be discarded.
-
Thanks for answer.
CornedBee,
I was just exploring a GUI designer idea.
So ill go with libs.
Thanks