This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: DLL creation problem




> From: DJ Delorie [mailto:dj@delorie.com]
> > 	So how do I make the above assignment (or any global variable
> > 	assignemnt) work as expected?
> 
> What we do is, in the header where you prototype the variable
> (i.e. the "extern int foo;" line), add a directive like this:
> 
> 	extern int foo __declspec(dllimport);
> 
> Note that you should *only* do this for the application; don't do it
> for the dll itself.
> 

Whats typically done is something like this:
#ifdef BUILD_XYZ
#define XYZAPI __declspec(dllexport)
#else
#define XYZAPI __declspec(dllimport)
#endif

and just write a header file like so:

XYZ.h might contain:

extern int foo XYZAPI;

Then when you're building the DLL, just define BUILD_XYZ.

Bill

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]