|
From: Tor L. <tm...@ik...> - 2000-12-20 20:48:24
|
> It makes the header file "jmorecfg.h" read > > --------------------------------------------------- > #if defined(_WIN32) || defined(__declspec) || !defined(STATIC) > #ifdef BUILD > #define GLOBAL(type) __declspec(dllexport) type > #define EXTERN(type) extern __declspec(dllexport) type > #else > #define GLOBAL(type) __declspec(dllimport) type > #define EXTERN(type) extern __declspec(dllimport) type > #endif > #else > /* a function referenced thru EXTERNs: */ > #define GLOBAL(type) type > /* a reference to a GLOBAL function: */ > #define EXTERN(type) extern type > #endif > --------------------------------------------------- I would like to raise an important point about this code: It is not good to use a generic identifier like "BUILD" (which is quite likely to clash with some end-user source code identifier) to switch between dllimport and dllexport in a header file. What if libjpeg is used by some *other* library, which also is built into a DLL. Then when compiling *that* library we want the relevant declarations in *that* library's header files to read as dllexport, but still the declarations in libjpeg's header files to read as dllimport. One should use library-specific identifiers, that are unlikely to clash, like "NOW_COMPILING_LIBJPEG" or whatever. --tml |