std libraries vs. personal libraries

Derek Parnell derek at psych.ward
Sat Mar 18 04:49:10 PST 2006


On Fri, 17 Mar 2006 08:06:07 +1100, jicman <jicman_member at pathlink.com>  
wrote:

>
> I have these two programs:
> // test.d
> private import std.string;
> private import std.stdio;
> private import std.date;
> private import std.file;
> private import std.recls;
> private import jic.lib.misc;
>
> int main(char[][] args) { return(0); }
>
> and
>
> // test0.d
> private import std.string;
> private import std.stdio;
> private import std.date;
> private import std.file;
> private import std.recls;
>
> int main(char[][] args) { return(0); }
>
>
> When I compile test.d, I get:
>
> 15:20:05.13>build -I.. test.d
> c:\dmd\bin\..\..\dm\bin\link.exe
> C:\cygwin\home\us319318\source\d\jic\lib\misc_bn+C:\cygwin\home\us319318\source\d\jic\lib\misc+RemFiles_bn+test,test.exe,,user32+kernel32,test.def/noi;
>
> and the size of the test.exe file is 162,844 bytes.  However, when I  
> compile
> test0.d, I get:
>
> 15:24:03.45>build -I.. test0.d
> c:\dmd\bin\..\..\dm\bin\link.exe  
> test0,test0.exe,,user32+kernel32,test0.def/noi;
>
> and the size of the test0.exe file is 86,556 bytes.
>
> Now, I see that my personal library is getting added also, but I am not  
> adding
> anything to the program.  Why is the personal library getting added by  
> the
> compiler when I am not calling any functions from it?
>
> Could it be build?

Yes. If the module 'jic.lib.misc' contains nothing that should be linked  
in, you can add a pragma to it to stop Build from linking it.

   version(build) pragma(nolink);

This can be added anywhere in the 'jic.lib.misc.d' source file.

Typically, you would do this if the source file only contained header info  
and no function bodies and/or public variables.

-- 
Derek Parnell
Melbourne, Australia



More information about the Digitalmars-d-learn mailing list