On Tuesday, 13 August 2013 at 06:56:11 UTC, Jacob Carlborg wrote:
No, it's not portable. Example, libraries on Posix are usually named "libfoo.a", on Windows they're named "foo.lib". As far as I know that is not handled by pragma(lib).

Yes, it is. pragma(lib, "foo") works on both systems. It passes the name "foo" to the linker, which knows about the cross platform differences. I use it all the time on Windows and Linux without any problems.


The problem people have with pragma(lib) is that gdc's architecture doesn't allow it; the front end in gcc can't pass an argument to the linker, and also that separate compilation with any compiler doesn't pass the pragma (its instruction is only in the .d file, not the .o). I don't see this as a problem with the feature - it doesn't have to work in every case to be very useful.

worst case, if it doesn't work, you're just doing it the way you would anyway. Even so, however, pragma(lib) can still serve to document the fact that the library is required.

In summary, pragma(lib) is great and you can have it when you pry it from my cold, dead hands.

Reply via email to