FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

pragma(link, ..) vs pragma(lib, ..) on Windows

 
Post new topic   Reply to topic     Forum Index -> DSSS
View previous topic :: View next topic  
Author Message
gc1



Joined: 18 Feb 2010
Posts: 7

PostPosted: Sun Mar 07, 2010 1:17 pm    Post subject: pragma(link, ..) vs pragma(lib, ..) on Windows Reply with quote

DSSS generates pragma(link, "library-name") statements in installed .di files

But on Windows pragma(link is not implemented, it gives an error message like:

    Error: pragma link unrecognized pragma(link)

How are other people handling DSSS on Windows ? Do you change the DSSS source code to create pragma(lib, ..) statements instead of pragma(link, ..) or do you run a script to edit the .di files ?

Is it true that pragma(lib, ..) is not implemented on Linux - which is presumably why DSSS generates pragma(link, ..) statements ?
Back to top
View user's profile Send private message
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Mon Mar 08, 2010 9:02 am    Post subject: Reply with quote

pragma(link) is a DSSS specific pragma that DMD can't handle. Therefore it must be wrapped in a version statement like this:
Code:
version (build)
{
    pragma(link, "name");
}


The initial reason (I think) why DSSS introduced the pragma link was because the linux version of DMD didn't implement it or it didn't work as it should. I think that GDC also doesn't implement it.

Second reason is that it is platform independent, for example you specify the name of the library without any pre or postfix. The convention for library names on posix platforms is libname.a and on Windows name.lib. Using pragma link you only specify the name like this:
Code:
pragma(link, "name");
and the compiler will automatically add the prefix and extension depending on the platform you compile on.

The third reason is that you can have pragma(link) in a library's header files and it will automatically link to the library. With pragma(lib) you can't. It only works with source files and not header files. This is issue has been reported: http://d.puremagic.com/issues/show_bug.cgi?id=2776
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DSSS All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group