uc/cmn/dllinterface.h File Reference
Detailed Description
Set of helper macros to declare and define classes that cross DLL boundaries. Inspired by
http://aegisknight.org/cppinterface.html article.
- Attention:
- Rules for classes declared with UC_DLL_INTERFACE_DECLARE:
-
These classes should be completely abstract, i.e. every method should be pure virtual or inline;
-
Don't use standard C++ library;
-
Don't use virtual destructors;
-
Don't use overloaded methods;
-
Use
__stdcall
calling convention for every pure virtual method (see UC_DLL_CALL);
-
Don't return struct/class instances from pure virtual methods; size of return type should be less or equal to
sizeof(int)
.
Rules for classes derived from classes declared with UC_DLL_INTERFACE_DECLARE:
-
Base class overridden methods should not throw exceptions;
-
Class should define virtual destructor if it can be inherited.
Define Documentation
#define UC_DLL_INTERFACE_DECLARE |
( |
IFace |
|
) |
|
Value:
protected: \
virtual void UC_DLL_CALL \
destroy##IFace() = 0; \
public: \
void operator delete(void* p) \
{ \
if(p) \
{ \
static_cast<IFace*>(p)->destroy##IFace(); \
} \
} \
private:
Every class supposed to pass DLL boundaries should have one occurrence of this macro in its declaration.
- See also:
- UC_DLL_INTERFACE_IMPL
- Parameters:
-
#define UC_DLL_INTERFACE_IMPL_BASE |
( |
IFace |
|
) |
|
#define UC_DLL_INTERFACE_IMPL_TOP |
#define UC_DLL_INTERFACE_IMPL |
( |
IFace |
|
) |
|
#define UC_DLL_INTERFACE_IMPL2 |
( |
IFaceA, |
|
|
IFaceB |
|
) |
|