From: Vincent T. <vt...@un...> - 2008-03-03 13:34:34
|
On Mon, 3 Mar 2008, Keith Marshall wrote: > On Monday 03 March 2008 07:38, Vincent Torri wrote: >> #ifdef _WIN32 >> # ifdef DLL_EXPORT >> # define EAPI __declspec(dllexport) >> # else >> # define EAPI __declspec(dllimport) >> # endif >> # define EAPI_DEF >> : >> : >> #endif >> >> we use EAPI in the declaration of functions that are exported, and >> EAPI_DEF in the definition of these functions. Is it correct ? > > No, I don't think so. With the above, `EAPI_DEF' is *always* going to > be defined as *nothing*. yes, that was intended. EAPI_DEF is for function definition. So I have something like: EAPI void foo(void) EAPI_DEF void foo (void) { *** } if i put __declspec(dllimport), i.e. EAPI, in front of both declaration and definition, I have an error from gcc (3.4.5). That's why I defined EAPI_DEF to nothing. > With the above #defines of `EAPI', I would think you want to just > declare everything to be implemented in your DLL with the `EAPI' > attribute. Then, in the compilation units which *implement* the DLL, > you `#define DLL_EXPORT', *before* you #include the header providing > the declarations. I'm compiling an autotooled library, so libtool defines DLL_EXPORT for objects used to create the shared library, and does not define it for objects used to create the static library. To summarize, with the current definition of EAPI / EAPI_DEF: * for object files used to create the dll, DLL_EXPORT is defined and the declarations and definitions of functions are: __declspec(dllexport) void foo(void); void foo(void) { *** } * for object files used to create the static lib, DLL_EXPORT is not defined and the declarations and definitions of functions are: __declspec(dllimport) void bar(void); void bar(void) { *** } Is it what I should do ? thank you Vincent Torri |