I am using ACE to get functions from a dynamically loaded DLL. The function symbol() below returns a void pointer, which I have to cast back to what it originally is.
typedef cBase * (_cdecl *typeCreateManager)( void );
// ...
ACE_DLL * m_pAceDll = new ACE_DLL;
m_pAceDll->open( "NameOfDll.dll" );
cBase * (_cdecl *pfunc)( void ); // declaration of function pointer
// can be replaced by "typeCreateManager pfunc;"
pfunc = (typeCreateManager)m_pAceDll->symbol("?createManager@@YAPAVcBase@@XZ");
// can be replaced by ???
cBase * pObject = (*pfunc)();
m_pAceDll->close();
Two questions:
Which C++ cast is appropriate instead of the C-like cast? Static or reinterpret?
Can I omit the typedef in the cast? What is the proper syntax? I don't want it to be visible everywhere my DLL is used. Since I only need it at a small number of places in the code I'd like to remove the typedef.