delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/11/13/15:47:30

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

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 AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019