This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]