Re: Queries about DLL Exports
"Mohammad Omer" <momer114@gmail.com> wrote in message
news:1164701235.787723.90380@n67g2000cwd.googlegroups.com
Igor Tandetnik,
I believe you can export a global variable the same way you export a
function: just mention its name in DEF file.
I did that and its working but I am not understands, how to use that
variable from that dll? I was created a variable in DLL project (name
exportInt, type int, default value 10 and global scope of DLL), define
name of variable in DEF file and project build successful. How I can
use that variable? I was tried following code for import variable
extern int exportInt;
it gives me some garbage value. Please tell me how I can use this
variable from DLL?
It turns out that, while you can use DEF file to export a global
variable, you still need __declspec(dllimport) to import it:
http://msdn2.microsoft.com/en-us/library/hyx1zcd3.aspx
"Note that when you export a variable from a DLL with a .def file, you
do not need to specify __declspec(dllexport) on the variable. However,
in any file that uses the DLL, you must still use __declspec(dllimport)
on the declaration of data."
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925