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: Global data in DLL's how?


Global variables declared in DLLs exist within the data
segment by default.   Each process attached to a DLL 
gets its own copy of the data segment, hence, its own 
private set of those globals.

I don't know if the Gnu/Cygnus development environment
supports this but the MS prescribed way to change the
default behavior of globals so that they may be shared
by all attached processes is to add a directive like the
following to your DLL's entry module:

#pragma data_seg( ".GLOBALS" )
int nProcesses =0;
int nThreads     =0;
#pragma data_seg()

BOOL WINAPI DLLMain( etc .....

Where nProcesses & nThreads are shared by all ...


Since you need it, test and let the rest of us know.

da bisk


----------
> From: Craig Setera <setera@us.ibm.com>
> To: gnu-win32@cygnus.com
> Subject: Global data in DLL's how?
> Date: Friday, May 22, 1998 7:13 AM
> 
> Let's see if I can explain what I think is happening in hopes that
someone
> can offer a decent solution.
> 
> I'm (still) trying to build DLL's for the GIMP.  There are 3 libraries
that make
> up GTK (the Gimp Toolkit).  GLib, GDK and GTK.  In GDK, there is a file
> that declares an number of global variables.  If I build each of these
into
> separate DLL's, I find that the global variables don't seem to be shared
> between GDK and GTK.  It appears that each DLL is getting its own copy
> of the variables rather than sharing a single copy.
> 
> So, other than providing functions (this would be a cleaner way to do it
> in the first place) to retrieve the information from GDK is there a way
to
> make sure that each of the DLL's has access to the same copy of the
> global data?
> 
> Thanks,
> Craig
> 
> 
> Craig Setera
> AS/400 Enterprise Java Development
> IBM Rochester
> setera@us.ibm.com
> (507) 253-3387 - Tie: 553-3387
> -
> For help on using this list (especially unsubscribing), send a message to
> "gnu-win32-request@cygnus.com" with one line of text: "help".
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


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