delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
MIME-Version: | 1.0 |
Subject: | Initializing a dll question / advise wanted |
Date: | Tue, 4 Nov 2003 19:04:52 +0100 |
X-MimeOLE: | Produced By Microsoft Exchange V6.0.6249.0 |
Message-ID: | <A3D1526C98B7C1409A687E0943EAC41001E975@obelix.askesis.nl> |
X-MS-Has-Attach: | |
X-MS-TNEF-Correlator: | |
From: | "Joost Kraaijeveld" <J DOT Kraaijeveld AT Askesis DOT nl> |
To: | <cygwin AT cygwin DOT com> |
X-MIME-Autoconverted: | from quoted-printable to 8bit by delorie.com id hA4I5CrJ013514 |
Hi all, I need to load two dll's and each dll must, upon loading, initialize a data structure. Both dll's must run on Windows 2000 and Linux. I have written some small code that should do the trick (see below). At this moment I make a distinction between Cygwin/MinGW on Windows and GCC on Linux. My questions: 1. Is this distinction needed or should it work the same (Linux) way for all three compilers? 2. If so, is the unloading of the dll's in the reverse order of loading and is that guaranteed somehow (that is, can I depend on it)? 3. If the distinction is needed, does Cygwin behave as GCC on Linux or does it behave as MinGW? TIA Joost Kraaijeveld Askesis B.V. Molukkenstraat 14 6524NB Nijmegen tel: 024-3888063 / 06-51855277 fax: 024-3608416 email: J DOT Kraaijeveld AT Askesis DOT nl web: www.askesis.nl /// Source file #ifndef DllMain_hpp #define DllMain_hpp static void attachDll(unsigned long anArg); static void detachDll(unsigned long anArg); #if defined (__MINGW32__) || defined (__CYGWIN32__) #warning "This must be Windows" #include <windows.h> extern "C" BOOL APIENTRY DllMain( HINSTANCE hInst, DWORD reason, LPVOID reserved ) { switch(reason ) { case DLL_PROCESS_ATTACH: { attachDll(0); break; } case DLL_PROCESS_DETACH: { detachDll(0); break; } } return TRUE; } #else // linux static void DllMainAttach() __attribute__((constructor)); static void DllMainDetach() __attribute__((destructor)); static void DllMainAttach() { attachDll(1); } static void DllMainDetach() { detachDll(1); } #endif // defined (__MINGW32__) || defined (__CYGWIN32__) #endif // DllMain_hpp -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |