DLL exported functions - calling conventions and return types
I've been trying to figure out if it matters which calling convention we use for DLL's exported functions. It seems that since both caller (one that loads the DLL and calls the function) and callee (DLL functions) reside in the same address space (i.e. same process), whether we use _stdcall or _cdecl as calling convention for the exported functions shouldn't matter. Is this correct?
Also, is there a restriction on the return type of the exported functions? I think primitive return types might be all allowed, but I wasn't sure about struct or class as a return type.
If I have something like
Code:
class CMyClass {
...
};
CMyClass _stdcall func()
{
...
}
Is this allowed?
Now, say that I have a function member (pointer) that points to some heap memory. Can I have the exported function returrn a pointer to this address, and both use and free the memory from the caller's code?