Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@sourceware.cygnus.com>
List-Subscribe: <mailto:cygwin-subscribe@sourceware.cygnus.com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin@sourceware.cygnus.com>
List-Help: <mailto:cygwin-help@sourceware.cygnus.com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner@sourceware.cygnus.com
Delivered-To: mailing list cygwin@sourceware.cygnus.com
Message-ID: <382DDDA3.D84AB37E@wanadoo.fr>
Date: Sat, 13 Nov 1999 21:52:36 +0000
From: Vincent Penne <vincent.penne@wanadoo.fr>
Organization: OVR/SasHipA
X-Mailer: Mozilla 4.05 [en] (X11; I; Linux 2.0.35 i586)
MIME-Version: 1.0
To: cygwin@sourceware.cygnus.com
Subject: Re: Building C++ library DLL
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Thanks again for quick answer !

> > But with a more complicate library, I still have some internal
compiler
> > error when using class that are defined as
> > class __declspec(dllimport) foo
>
> This is of course illegal. You cannot *define* an imported class.
That's
> where all those preprocessor macros come in -- you declare when
importing,
> define when exporting.

Here I am a bit surprised. What I am doing,, and have seen done often,
is something like this

#ifdef LIBRARY
#define API __declspec(dllexport)
#else
#define API __declspec(dllimport)
#endif

The library is compiled with the LIBRARY symbol set, and the header
files contains things of that sort

class API foo {
 ...
};

API void some_function();

When the library is used, the same header files are used. Do you mean
that doing this is not allowed ? I should rather do

#ifdef LIBRARY
#define API  /* nothing */
#else
#define API __declspec(dllimport)
#endif
#define DECL_API __declspec(dllexport)

and then in sources of the library,

DECL_API void some_function()
{
 ...
}

This is of course a lot more annoying for the programmer when porting
from a unix library where no such stupid things are necessary ...

MSVC++ allow the first method ...



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

