[cfe-dev] Reflection
John McCall
rjmccall at apple.com
Tue Dec 14 13:20:40 PST 2010
On Dec 14, 2010, at 1:08 PM, David Chisnall wrote:
> On 14 Dec 2010, at 19:44, Russell Harmon wrote:
>
>> What? The struct definition doesn't provide an authoritative definition?
>
> The struct definition can be in a header, and very often is. The header can be included in, potentially, hundreds of compilation units. For example, any file that includes Cocoa.h or Foundation.h (i.e. pretty much any Objective-C source file) will contain definitions of the NSRange structure. Where would you emit the metadata? One copy in every single compilation unit that included this header?
>
> In contrast, every Objective-C class has exactly one @implementation directive for the class, which contains all of the instance variable metadata and all of the method / property metadata for ones that are declared on the class. It can have additional @implementation directives for categories, but these contain abridged metadata (i.e. just the additions made by the category).
>
> For C++, the vtable and RTTI data is emitted in the compilation unit that contains the definition of the first virtual member function (I think that's specified by C++, but I'm not overly familiar with the spec, so it may just be specified by the Itanium ABI).
It's just the Itanium ABI. It's enabled by a language rule which says that non-inline virtual functions must be defined in exactly one place, though.
John.
More information about the cfe-dev
mailing list