Click here to Skip to main content
15,888,454 members
Home / Discussions / COM
   

COM

 
AnswerRe: How to access member functions of coclass from its Interface Pin
mandanani8-Jan-08 20:42
mandanani8-Jan-08 20:42 
AnswerRe: How to access member functions of coclass from its Interface Pin
prasad_som9-Jan-08 1:29
prasad_som9-Jan-08 1:29 
QuestionHow to using C# Class Library in VC++/COM Pin
Member 42194196-Jan-08 23:45
Member 42194196-Jan-08 23:45 
GeneralRe: How to using C# Class Library in VC++/COM Pin
Mike Dimmick7-Jan-08 11:00
Mike Dimmick7-Jan-08 11:00 
GeneralCOM on MAC Operating System Pin
Gupta Suraj6-Jan-08 22:08
Gupta Suraj6-Jan-08 22:08 
GeneralATL_NO_VTABLE means ..... Pin
tasumisra6-Jan-08 18:18
tasumisra6-Jan-08 18:18 
GeneralRe: ATL_NO_VTABLE means ..... Pin
CPallini6-Jan-08 22:00
mveCPallini6-Jan-08 22:00 
GeneralRe: ATL_NO_VTABLE means ..... Pin
Mike Dimmick6-Jan-08 23:58
Mike Dimmick6-Jan-08 23:58 
ATL_NO_VTABLE is a macro which tells the compiler (if supported) not to generate a vtable for a class. For the Microsoft compiler it expands to __declspec(novtable).

The Microsoft compiler implements virtual function calls as indirect calls through a table of function pointers, called the vtable. It locates the appropriate vtable through a hidden member in each object of the class called the virtual function pointer or vfptr. In each class's constructor (where the class or any of its bases have virtual functions), the vfptr is initialised to point to that class's vtable. Because C++ says to run each constructor, from base to most-derived class, in turn, at the beginning of executing each constructor the vfptr points to that class's vtable. Ultimately, when all the constructors have run, it points to the most-derived class's vtable.

Calling an abstract (pure virtual, with no implementation) function from a constructor is not allowed. There are conditions - such as if you call a non-virtual function from a constructor which in turn calls an abstract function - where you can accidentally do this. To fail cleanly, Visual C++ generates an R6025 error, 'pure virtual function called'. A pointer to the function that implements this occupies the abstract function's slot in the vtable.

If a class is never actually used as a concrete class, that is, no objects are ever created of that class, only of derived ones, the vtable will never be used and is therefore redundant. To save the cost of setting the vfptr unnecessarily, __declspec(novtable) tells the compiler not to generate this code. In addition, if the compiler and linker options are correct (/Gy for the compiler, and /opt:ref for the linker), the linker will discard the vtable if it's not otherwise referenced. If you do use the class as a concrete class, though, the vfptr will still be pointing to the last base that wasn't marked, or if all bases are marked __declspec(novtable), it will be uninitialised and you'll probably crash or corrupt memory.

ATL does not directly construct objects of your class. Instead, the OBJECT_MAP macros declare instantiations of CComObject using your class (where the template derives from your class). Therefore if you only use your classes with these macros, ATL_NO_VTABLE is safe.


DoEvents: Generating unexpected recursion since 1991

QuestionHow to call a function in DLL Pin
chaitannya_m4-Jan-08 4:12
chaitannya_m4-Jan-08 4:12 
QuestionVS2008, MIDL compiler bug Pin
Gary Wheeler4-Jan-08 4:10
Gary Wheeler4-Jan-08 4:10 
GeneralRe: VS2008, MIDL compiler bug Pin
Mike Dimmick6-Jan-08 8:27
Mike Dimmick6-Jan-08 8:27 
GeneralRe: VS2008, MIDL compiler bug Pin
Gary Wheeler7-Jan-08 1:16
Gary Wheeler7-Jan-08 1:16 
GeneralRe: VS2008, MIDL compiler bug Pin
Mike Dimmick7-Jan-08 10:58
Mike Dimmick7-Jan-08 10:58 
GeneralRe: VS2008, MIDL compiler bug Pin
Gary Wheeler8-Jan-08 0:52
Gary Wheeler8-Jan-08 0:52 
GeneralRe: VS2008, MIDL compiler bug Pin
Mike Dimmick8-Jan-08 9:40
Mike Dimmick8-Jan-08 9:40 
GeneralRe: Calling ActiveX DLL from MFC - passing arrays Pin
mla1543-Jan-08 10:05
mla1543-Jan-08 10:05 
GeneralRe: Calling ActiveX DLL from MFC - passing arrays Pin
CPallini3-Jan-08 10:53
mveCPallini3-Jan-08 10:53 
GeneralRe: Calling ActiveX DLL from MFC - passing arrays Pin
mla1543-Jan-08 11:17
mla1543-Jan-08 11:17 
QuestionRe: Calling ActiveX DLL from MFC - passing arrays Pin
CPallini3-Jan-08 21:11
mveCPallini3-Jan-08 21:11 
GeneralRe: Calling ActiveX DLL from MFC - passing arrays Pin
mla1544-Jan-08 3:39
mla1544-Jan-08 3:39 
AnswerRe: Calling ActiveX DLL from MFC - passing arrays Pin
Lim Bio Liong4-Jan-08 23:24
Lim Bio Liong4-Jan-08 23:24 
GeneralRe: Calling ActiveX DLL from MFC - passing arrays [modified] Pin
mla1547-Jan-08 4:24
mla1547-Jan-08 4:24 
GeneralRe: Calling ActiveX DLL from MFC - passing arrays Pin
Lim Bio Liong7-Jan-08 15:10
Lim Bio Liong7-Jan-08 15:10 
QuestionMSSOAPLib30 SoapReader30Class LoadWithParser Error Pin
miauwmiauwmiauw2-Jan-08 19:31
miauwmiauwmiauw2-Jan-08 19:31 
QuestionHow to Use events from VB.NET in VC.NET? Pin
ritz12341-Jan-08 2:38
ritz12341-Jan-08 2:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.