Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

#pragma for delay loading a DLL?

137 views
Skip to first unread message

Ben Brandt

unread,
Feb 14, 2008, 3:34:15 PM2/14/08
to

In a header file I have an interface with a factory function like:
extern "C"
MyInterface* __IMP_EXP GetMyInterface();

Below that I have the import library needed included in a pragma:
#pragma link "MyDLL.lib"

Is there a pragma that I can add in the code to mark MyDLL.dll as delay-loaded
or pass the -d"MyDLL.dll" to the linker? I have an unknown number of projects
and don't want to search out and modify the project options on each one.
I'd much rather add one line of code in one file and be done with it.

Thank you,
Ben Brandt


Remy Lebeau (TeamB)

unread,
Feb 14, 2008, 3:59:44 PM2/14/08
to

"Ben Brandt" <Be...@nospam-flowcal.com> wrote in message
news:7c7034de3e8e8...@forums.borland.com...

> Is there a pragma that I can add in the code to mark
> MyDLL.dll as delay-loaded or pass the -d"MyDLL.dll" to the linker?

In VC++ v6 (but not in v7), you can use #pragma command for that, ie:

#pragma comment(lib, "MyDll.lib")
#pragma comment(linker, "/delayload:MyDLL.dll")

I don't know if Borland/CodeGear's compiler supports the "linker" flag.


Gambit


Darko Miletic

unread,
Feb 15, 2008, 8:42:10 AM2/15/08
to

Unfortunately this is not permitted. In theory #pragma option could be
used for this but unfortunately it does not permit passing of that
option. #pragma comment does not support passing options to linker.
Conclusion is that you must supply -d option as a command line parameter.

0 new messages