From: sos AT prospect DOT com DOT ru (Sergey Okhapkin) Subject: RE: Can't Reference Stderr from a DLL 18 Mar 1997 14:33:55 -0800 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <01BC3394.D4831CB0.cygnus.gnu-win32@gater.krystalbank.msk.ru> Original-To: "gnu-win32 AT cygnus DOT com" , "'John Cerney'" Encoding: 58 TEXT Original-Sender: owner-gnu-win32 AT cygnus DOT com John Cerney wrote: > > nothing about it! The only way I see is to place reent_data structure to > > cygwin.dll and modify fork() code to create a copy of it in a child > > process... > > main.c calls impure_setup() in the dll with main's impure_ptr as its argument > impure_setup() in init.cc takes the impure_ptr from main and copies the > value to its (the dll's) local copy of impure_ptr. It's not a suitable way for me :-( It requires explicit call to impure_setup() for _each_ project's dll! This will prevent easy porting (X stuff for example). If reent_data will be exported from within cygwin.dll, then it will be possible to write #include extern struct reent *_impure_ptr, *__imp_reent_data; int WINAPI dll_main(HANDLE a, DWORD reason, void *q) { switch (reason){ case DLL_PROCESS_ATTACH: break; case DLL_PROCESS_DETACH: break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; } _impure_ptr = __imp_reent_data; return 1; } and link this file to every DLL. Function dll_main (declared as entry point on ld's command line) will be called automatically after loading dll, and will set up dll's _impure_ptr right without explicit call to it! Number of dll's may vary - initialisation for each dll will be done automatically. > I guess this means that I will have to create a include file that does > something like this for every global variable I want to access: > #define variableName (*_imp_variableName) This technique is used in a port of X libraries with MSVC :-) > > I wish there was a more transparent way of doing this. I believe VC++ allows > you to access global variables to/from DLLs without going to this trouble. I am > trying to build the VC++ win32 port of perl 5.003 now to verify if this is > true. VC++ requires explicit dllimport/dllexport declarations. Almost the same way... -- Sergey Okhapkin Moscow, Russia Looking for a job. - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".