Regarding Windows DLL's and variables, the following is generated
by the VC6 wizard for the DLL header file for just such a thing:
#ifdef MYDLL_EXPORTS
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif
extern MYDLL_API int nTestdll;
MYDLL_API int fnTestdll(void);
The above, when contained within the product's header file,
accomplishes the necessary objective quite cleanly. To
accommodate Unix/VMS/Windows, the defines may be
wrapped by an #ifdef WIN32.
Global variables are easily accessible via this mechanism.
Of course, even though the DLL may be loaded only one
time in memory, the global data it contains is NOT shared
among multiple processes. The initial value may be the same
for each process upon startup but modifications to the vars
in one process are not seen by another process. Also,
modify access to those vars by multiple threads within the
same process must be synchronized...
----- Original Message -----
From: Toomas Kiisk <[EMAIL PROTECTED]>
To: OpenSSL Development <[EMAIL PROTECTED]>
Sent: Wednesday, January 03, 2001 4:37 AM
Subject: Re: Windows, DLLs and variables.
> On Fri, 29 Dec 2000, Dr S N Henson wrote:
>
> > AFAICS this needs a "DATA" declaration in the DEF file *and* a custom
> > header declaration otherwise it doesn't work (linker errors or invalid
> > data).
> >
> > The header declaration is where things get more interesting. When
> > compiling code that is going to be linked into the DLL you need to
> > precede the variable with:
> >
> > _declspec( dllexport )
> >
> > however when linking to these variables you need:
> >
> > _declspec( dllimport )
> >
> > So the declaration needs to be different according to whether the DLL
> > code is being compiled or linked to.
> >
>
> I did some testing, recording a symbol in EXPORTS section
> of DEF file exports it without __declspec(dllexport) hack
> (according to dumpbin /exports). I was even able to link a
> program against this library. However, it did not work without
> declaring imported symbol __declspec(dllimport). By the way,
> it appeared that DEF file DATA keyword is broken (or maybe it
> is just too poorly documented). I used m$ visual studio 6, SP3.
>
>
> --
>
> vix
>
> ______________________________________________________________________
> OpenSSL Project http://www.openssl.org
> Development Mailing List [EMAIL PROTECTED]
> Automated List Manager [EMAIL PROTECTED]
>
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]