Archived

This topic is now archived and is closed to further replies.

krakrazor

Classes in DLL

Recommended Posts

krakrazor    122
How do i use a class in a runtime linked DLL? i wanna use this class: #ifdef CFSIO_EXPORTS #define CFSIO_API __declspec(dllexport) #else #define CFSIO_API __declspec(dllimport) #endif typedef int CFSERROR; class CFSIO_API CFSio { private: CFSERROR e_laste; // last error BOOL b_ready; // are we ready to use this handle? HANDLE h_file; // handle to file public: CFSio() { b_ready = FALSE }; //Make sure CFSio(LPCTSTR *filename); ~CFSio(); }

Share this post


Link to post
Share on other sites
psykr    295
The thing about using classes in a DLL is the issue of name mangling in C++. Different compilers can give different names to the same functions, so there''s really no *safe* way to do it. IIRC, if you don''t care about compatibility there is a way o do it in Visual C++ 6.0 (and probably other compilers), but otherwise the only way I have heard of is to return a pointer to the class. You have to declare C-style naming, wrapping things in an extern "C" block.. I haven''t done this in a while, so google > me.

Share this post


Link to post
Share on other sites