K_GLOBAL_STATIC and other macros

Matthias Kretz kretz at kde.org
Fri Apr 13 11:41:19 BST 2007


On Friday 13 April 2007 12:37, Thomas Zander wrote:
> > K_GLOBAL_STATIC(MyType, name)
> >
> > Usage:
> >    [...]
> >    name->member = foo;
> >    name->setFoo(foo);
> >    MyType *ptr = name;
> >    MyType &ref = *name;
> >
> > I.e., "name" behaves just like a pointer to MyType (MyType*).
>
> I'm sorry; the construct "MyType(MyType*)" is unknown to me.  I still
> don't really know how to use this.

read
K_GLOBAL_STATIC(Type, name)
as
Type *name = new_on_first_access Type();

where the new_on_first_access means that the Type::Type() ctor is only called 
the first time the code accesses the name pointer. Also you don't have to 
care about destruction (except for what I said in my other mail to this 
thread).

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de




More information about the kde-core-devel mailing list