May 6, 2014

[C++] virtual table / RTTI during code gen and linking

Kind of forgetting this rule and what's underneath ^^

To be more clear, Mr. Honza Hubička 's nice articles mentioned:

"There are several ways to overcome redundant compilation. The most transparent one is the concept of keyed methods. If class define at least one method that is not inline, we know that there is one compilation unit defining it. Therefore all class data are located into that unit."

Provide a Virtual Method Anchor for Classes in Headers

If a class is defined in a header file and has a vtable (either it has virtual methods or it derives from classes with virtual methods), it must always have at least one out-of-line virtual method in the class. Without this, the compiler will copy the vtable and RTTI into every .o file that #includes the header, bloating .o file sizes and increasing link times.

Reference:

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.