www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - question regarding binary size

reply Frank Skare <frank_skare yahoo.de> writes:
I'm new to D and C++ and wonder what effects binary size. I'm experienced with
.NET and like that it's 100% OOP and produces relative small binaries. Using
C++ with a library like wxWidgets which is OOP and targets different platforms,
is it right that the pre processer strips most of the platform dependedend code
of multi platform libraries like wxWidgets?

Let's assume I make a instance of a class defined in wxWidgets but don't call
any methods in it, will all the code of the class end up in the binary and all
code of classes referenced in that class? If so then I don't understand how a
C++ OOP programmer can accept the resulting increase in binary size and
compilation time. I wonder if something like .NET's extension methods could
have fixed this problem. Extension methods is a trick to use static methods
like instance methods.
Feb 06 2008
parent Sergey Gromov <snake.scaly gmail.com> writes:
Frank Skare Wrote:

 is it right that the pre processer strips most of the platform dependedend
code of multi platform libraries like wxWidgets?
Yes.
 Let's assume I make a instance of a class defined in wxWidgets but don't call
any methods in it, will all the code of the class end up in the binary and all
code of classes referenced in that class?
If you link a library into your application, and some function never gets called, it is dropped out by a linker. If you build a dynamic library, and some function never gets called from any of exported functions, it is dropped out by a linker. If you create an instance, all the methods called and data referenced from its constructor will survive.
 If so then I don't understand how a C++ OOP programmer can accept the
resulting increase in binary size and compilation time. I wonder if something
like .NET's extension methods could have fixed this problem. Extension methods
is a trick to use static methods like instance methods.
Feb 06 2008