From: dtauritz AT WI DOT LeidenUniv DOT NL (D.R.Tauritz) Organization: Leiden University, Dept. of Mathematics & Computer Science, The Netherlands Subject: Re: coff format? To: dj AT stealth DOT ctron DOT com (DJ Delorie) Date: Mon, 31 Oct 1994 21:20:21 +0100 (MET) Cc: djgpp AT sun DOT soe DOT clarkson DOT edu, dliu AT faraday-gw DOT njit DOT edu >> On Sun, 30 Oct 94 16:23:02 -0500, DJ Delorie wrote: >> >> Oh, there is an another question, I don't know how a program can use a >> global variable in dll. > >I've never figured out how to manage that either, otherwise djgpp >would have been using shared libraries a long time ago :-) You can use a global variable in your client which was declared in your DLL as well as a global variable in your DLL which was declared in your client. An example of how to use a global variable in your client which was declared in your DLL: your_dll.h ... extern int var; ... your_dll.c ... int var; ... your_client.c #include "your_dll.h" int main() { ... int *var; ... var=(int *) dll_lookup(dll, "_var"); ... } An example of how to use a global variable in your DLL which was declared in your client: your_dll.c ... extern int *var; ... your_client.c ... int *var; ... int main() { ... dll_register("_var",&var); ... } Note that the first example defines a global variable of type int, while the second example defines a global variable of type *int, just to prove both are possible and of course to confuse you ;-) Daniel ----------------------------------------------------------------------------- | Daniel R. Tauritz | Maintainer of the | | E-mail: dtauritz AT wi DOT leidenuniv DOT nl | Aria FAQ & Support List | | Department of Mathematics & Computer Science | Aria Internet Department | | University of Leiden | Aria Mailing List | | The Netherlands | Leiden Audio Archives | ----------------------------------------------------------------------------- | The Aria Internet Department: ftp.wi.leidenuniv.nl:pub/audio/aria | | The Aria Mailing List : To : aria-request AT wi DOT leidenuniv DOT nl | | Subject: subscribe | -----------------------------------------------------------------------------