export variables in dlls

flyker flyker at everys.com
Fri Aug 8 06:23:12 CDT 2003


example:

-------------------------------------------------
main.cpp

#include <stdio.h>
#include <windows.h>

extern "C" __declspec(dllimport) void xxx(char *str, ...);
extern "C" __declspec(dllimport) char *zzz;

int WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR szCmdLine, int)
{
   xxx("blahblah\n", 1, 2, 3);
   printf(zzz);
   return 0;
}
---------------------------------------------------

mylib.cpp

#include <stdio.h>
#include <windows.h>

extern "C" __declspec(dllexport) void xxx(char *str, ...);
char zzz[80];

void xxx(char *str, ...)
{
   printf(str);
   lstrcpy(zzz, "12345\n");
   printf(zzz);
}
----------------------------------------------------

mylib.dll.spec

@ varargs xxx(str)
@ extern zzz
-----------------------------------------------------

mylib.cpp compiled successfully in mylib.dll.so
main.cpp compiler error: undefined reference to `zzz'

What I do wrong ???
How to export variables ???

And another question: how can i export functions such as 
ClassName::Function();




More information about the wine-devel mailing list