Previous Entry Share Next Entry
01:51 pm, 13 Jul 06

gcc vague linkage

GCC 4.1.1: Vague Linkage discusses how gcc decides where to stick the object code for various bits that don't obviously belong in a particular file, such as vtables:
If the class declares any non-inline, non-pure virtual functions, the first one is chosen as the “key method” for the class, and the vtable is only emitted in the translation unit where the key method is defined.

Note: If the chosen key method is later defined as inline, the vtable will still be emitted in every translation unit which defines it. Make sure that any inline virtuals are declared inline in the class body, even if they are not defined there.
So many details to remember!