aa*******@gmail.com schrieb:
For example, right now I'm sticking "__declspec(dllexport)" in front
of each of my classes. I guess I can still make it work on Unix
bydefing __declspec(x) to be an empty macro, but that's
embarrassing.
Is there a better solution?
Normally this __declspec() stuff is already in a global #define
because in most cases you use the same header for compiling the
library (this needs __declspec(dllexport)) and for using the library
(this needs __declspec(dllimport)). So the class definitions normally
contain something like this:
#ifdef BUILD_LIB
#define LIB_CLASS __declspec(dllexport)
#else
#define LIB_CLASS __declspec(dllimport)
#endif
class LIB_CLASS MyClass {
// ...
};
If you now want to have portable libraries you must just extend the
LIB_CLASS macro. For most Unix compilers you would leave it blank.
Note: you need to define this macro just on one single place in the
entire project, so it's not really much effort.
T.M.