Program size, linking matter, and static this()

Steven Schveighoffer schveiguy at yahoo.com
Mon Dec 19 10:22:50 PST 2011


On Mon, 19 Dec 2011 13:09:42 -0500, Walter Bright  
<newshound2 at digitalmars.com> wrote:

> On 12/19/2011 7:17 AM, Steven Schveighoffer wrote:
>> On Fri, 16 Dec 2011 17:55:47 -0500, Walter Bright  
>> <newshound2 at digitalmars.com>
>> wrote:
>>> For example, in std.datetime there's "final class Clock". It inherits  
>>> nothing,
>>> and nothing can be derived from it. The comments for it say it is  
>>> merely a
>>> namespace. It should be a struct.
>>
>> Although I don't disagree with you that it should be a struct and not a  
>> class,
>> does it have anything in its vtbl anyways if it's final?
>
> Yes. The pointers to Object's functions, and a pointer to the TypeInfo  
> for that class.

Well pointers to Object's functions shouldn't add any bloat.  The TypeInfo  
may, but that shouldn't pull in any real code from the module, right?

>> I'm just trying to
>> understand what gets pulled in when you import a module with static  
>> ctors...
>
> Write some trivial code snippets, compile them, and take a look at the  
> object file with obj2asm.

I'll rephrase -- I'm trying to understand what's *supposed* to happen :)   
Trusting that the compiler is doing it right isn't always correct.  Though  
it probably is in this case.

-Steve


More information about the Digitalmars-d mailing list