From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7733 invoked by alias); 30 Mar 2005 14:15:38 -0000 Mailing-List: contact pthreads-win32-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sources.redhat.com Received: (qmail 7630 invoked from network); 30 Mar 2005 14:15:24 -0000 Received: from unknown (HELO mx1.mail.bg) (193.201.172.114) by sourceware.org with SMTP; 30 Mar 2005 14:15:24 -0000 Received: from localhost (web1.mail.bg [193.201.172.98]) by mx1.mail.bg (Postfix) with ESMTP id F206B72A460D for ; Wed, 30 Mar 2005 17:15:08 +0300 (EEST) Received: from sun.fadata.bg (sun.fadata.bg [213.240.249.67]) by mail.bg (mail.bG Webmail 4.0.1) with HTTP for ; Wed, 30 Mar 2005 17:15:08 +0300 Message-ID: <1112192108.9a7b65f2515a2@mail.bg> Date: Wed, 30 Mar 2005 14:15:00 -0000 From: Dimitar Panayotov To: pthreads-win32@sources.redhat.com Subject: Static link (MSVC), alteration proposal MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1251" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable User-Agent: mail.bG Webmail 4.0-cvs X-SW-Source: 2005/txt/msg00050.txt.bz2 Hello. I show (as short as I can) a small note about statically linking to the Pthreads-Win32 library. My deprecation: why using _DLL macro to determine whether to link statically or dynamically? As you know, _DLL is used by the Microsoft headers; when defined, it links your app/lib/dll with an import library, which by itself points to the dynamically linked libraries, containing implementation of the C-Runtime Library on Win32. When _DLL not defined, C-Runtime is linked statically into your app/lib/dll. So, why the type of the linkage with the C-Runtime is bound to the type of linkage with Pthreads-Win32? In order to link my dll with Pthreads-Win32 statically, I had to do some minor changes: 1. Code in which I altered: #ifdef _DLL # ifdef PTW32_BUILD # define PTW32_DLLPORT __declspec (dllexport) # else # define PTW32_DLLPORT __declspec (dllimport) # endif #endif with: #ifdef PTW32_DLL # ifdef PTW32_BUILD # define PTW32_DLLPORT __declspec (dllexport) # else # define PTW32_DLLPORT __declspec (dllimport) # endif #else #define PTW32_DLLPORT #endif You surely realize what I do: First, I use a separate macro to determine whether to link statically or dynamically to Pthreads-Win32. Second, if you not explicitly define PTW32_DLLPORT as an empty macro, MSVC compiler expands it to __declspec(dllimport), no matter of the fact, that the preprocessor does not actually enter in the #ifdef PTW32_DLL block!! It's so funny. Of course, I did not wasted my time to check some strange implications which could be made by the MSVC compiler, since it always knows better than you what you actually want. :) 2. In and preprocessor code was similar, with the difference that there were no #ifdef _DLL. There I changed the code exactly as in 3. In I altered the following code: #include with: #ifdef PTW32_DLL #include #endif --- The result of all this is: when you do not define PTW32_DLL in your build, you will be sure that Pthread-Win32 function's declarations will not contain __declspec(dllexport) / __declspec(dllimport). Also, when you build your own DLL, you assure that no conflict will occur with the Pthread-Win32's DllMain(). Sorry for the bad English, it's not my native language. Of course, one human does not need to be a genius to note such things, nor will I pretend to be very smart for writing this note. :) I just hope it to be useful. --------------------- | Dimitar Panayotov | | develop@mail.bg | | +359886420488 | --------------------- ----------------------------- "=CA=EE=ED=F1=F2=E0=ED=F2=E8=ED" - =C4=E6=EE=ED =CA=EE=ED=F1=F2=E0=ED=F2= =E8=ED (=CA=E8=E0=ED=F3 =D0=E8=E9=E2=F1) =E2=E5=F7=E5 =E5 =E1=E8=EB =E2 =E0= =E4=E0. =D2=EE=E9 =E8=EC=E0 =E4=E0=F0=E1=E0=F2=E0 =E4=E0 =F0=E0=E7=EF=EE=E7=ED=E0= =E2=E0 =E4=E5=EC=EE=ED=E8=F2=E5, =EF=F0=E8=E5=EB=E8 =F7=EE=E2=E5=F8=EA=E8 = =EE=E1=EB=E8=EA. http://www.mail.bg/info/?action=3D1200&title=3D%CA%EE%ED%F1%F2%E0%ED%F2%E8%= ED%20%282005%29&date