Original Post
How would the def file look for exporting a class, or if not using a def file, where would you put declspec(dllexport) and/or extern "C". I searched google for answers but to no avail.
class __declspec(dllexport) CTest{ //blah};class IMyClass{public: // Important, this ensure the correct destructor // is called when a derived class is destroyed. virtual ~IMyClass() =0; // The interface to your class virtual void DoSomething() = 0;};class MyClass : public IMyClass{public: // The virtual keywords aren't strictly necessary, // but I usually put them in to make it clear they're // implementing functions from the base class virtual ~MyClass() { ... } virtual void DoSomething() { ... }};// I've used a raw pointer here, using smart pointers// would be better (but watch out for problems with// the DLL using a different heap, which it probably// will if you're using 2 different compilers)declspec(dllexport) IMyClass* CreateMyClass(){ return new MyClass();}// Objects should be deleted from inside the DLL since the// calling executable could be using a different heap, hence// the existence of this functiondeclspec(dllexport) void DestroyMyClass(IMyClass* obj){ delete obj;}Quote:You can't, but in practice, they usually are. Multiple or virtual inheritance isn't as likely to work, however.
Original post by cnstrnd
To follow on this particular subject :
How can one be sure the virtual functions in the v-table are ordered the same by different compilers ?
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more