Thursday, April 28, 2011

Export/Import template class

I am thankful to this really nice article which helped me to resolve issues to export/import template class instance.
I surfed a lot and couldn't found a way to export/import the whole template class. Instead we need to do explicit template instantiations to achieve this.

For e.g. instead of whole class you do it like this:
template class DLLEXPORTIMPORTAPI Container < int >;

//DLLEXPORTIMPORTAPI is __declspec(dllexport) or __declspec(dllimport)

Wednesday, April 20, 2011

New Findings While DLLization

I faced a problem where the address of a structure (as a void pointer) is passed from one DLL 'A' to 'B'. Idea is that you store these void pointers to DLL 'B' and call them latter on the basis of some assigned keys. This structure contains data variables and some others functions/structure address too.
So, while fetching the address back from DLL 'B' rest of address pointed by the structure gets corrupted.
So, the questions arises are:
1) Shall we do a deep copy and pass structure instead of pointers.
2) Is passing pointers across DLL's is acceptable?

While looking for the solution I came across this interesting article from IBM. http://publib.boulder.ibm.com/infocenter/zvm/v5r3/index.jsp?topic=/com.ibm.zvm.v53.dmsa3/hdcode.htm.
Below are few highlights of this article:
1) A source file that contains a function call through a pointer that may point to either a function or function descriptor must be compiled as non-DLL code.
2) A source file that calls imported functions or imported variables by name must be compiled as DLL code.
3) A source file that contains a comparison of function pointers that may be DLL function pointers must be compiled as DLL code.
4) A source file that may pass a function pointer to DLL code through a parameter or a return value must be compiled as DLL code.

Aisha_Record_Final.wmv