Functions that should be static

Christian Costa titan.costa at
Mon Dec 22 09:03:04 CST 2008

Francois Gouget a écrit :
> On Sat, 20 Dec 2008, Christian Costa wrote:
> [...]
>> If you have a class A (with methods implemented in file 1) that inherits from
>> another class B (methods in file B).
>> The class A may overrides some methods of B which may become unused if B is
>> never instanciated and B methods not reused.
>> They will be tracked by your script then.
>> We could make these functions static or worst remove then but from object
>> programming pov is not good.
> I don't see any reason not to make the methods of B static, whether 
> class A exists or not. Note that 'static' does not prevent a function 
> from being called from another object file if you give a pointer to them 
> to that other file (as you do with the virtual table).
> Also the compiler will not complain that these functions are unused 
> because they are indeed used: you take their address.
Yes. That's right we can pick the function address from a vtable but in 
that case
we cannot build another one statically as we use to i.e :

const IPinVtbl MyInputPin_Vtbl = {
InputPin_Vtbl.QueryInterface, <= not a constant

The compiler will complain this is not a constant. We could never build 
a vtable statically except for the top base class.
And how could we build a vtable dynamically from another one which is 
also build dynamically ?
I guess, we need to rely on constructor of the parent class which will 
call in turn his own parent and so on. This is a big change.
Maybe it's off topic, but msvcirt exports methods as well as vtables. I 
don't know how all of this works !

More information about the wine-devel mailing list