EXPORT_Cing functions and virtual functions

Login to reply to this topic.
Thu, 2006-10-26 20:34
Joined: 2006-05-09
Forum posts: 78
Hi

I thought for a function to be used outside of a DLL it must be declared using IMPORT_C/EXPORT_C. But I've seen some code where this isn't the case, but the function is still able to be used outside of the DLL.
The function is virtual, so does that mean virtual functions don't need to be EXPORTED? If so, then why are there a lot of virtual functions that are EXPORTED?

Fri, 2006-10-27 06:01
Joined: 2003-09-29
Forum posts: 32
Re: EXPORT_Cing functions and virtual functions
Hi,

virtual functions are usually called through the virtual table of the class, which is either exported automatically (3rd. ed. EABI) or derived from the class declaration (BWINS and BMARM). So, in general virtual functions don't have to be exported from the classes if the functions are only intended to be used outside the DLL.

However, if the class is designed to be a base class for other classes outside the DLL and the virtual functions have to be called from the derived classes using syntax CBaseClass::VirtualFunction(), then the call to the function is made statically and thus the function has to be exported from the DLL to be callable. Many if not most of the classes of SDK export also virtual functions because those classes are intended to be used as base classes for user defined classes.

--
Jari

Jari

  • Login to reply to this topic.