Can Q_GLOBAL_STATIC replace KStaticDelete ?

Oswald Buddenhagen ossi at kde.org
Tue Jan 23 08:16:17 GMT 2007


On Mon, Jan 22, 2007 at 07:52:59PM -0500, Michael Pyne wrote:
> On Monday 22 January 2007 18:39, Alexander Neundorf wrote:
> > On Tuesday 23 January 2007 00:29, Thiago Macieira wrote:
> > > Thiago Macieira wrote:
> > > >>+static bool _k_static_##NAME##_destroyed = false;
> > > >
> > > >Don't initialise the variable. This saves us 4 bytes in the
> > > >executable.
> > >
> > > Forget what I said above. The compiler is smart enough to know
> > > that initialising to 0 is the same as placing on the .bss. So, by
> > > all means, initialise it.
> >
> > Sure ? I didn't know that. All versions of gcc ? In all optimization
> > levels ? For variables of which types ?
> 
> I don't know the answers to any of those questions but I don't think
> it really matters.
> 
only newer gccs do that, newer being defined as something around 2000.
dunno about non-gcc compilers.

> I'd rather be safe and initialize a value and perhaps take a 4 byte
> hit rather than leave it uninitialized and rig it so that the value is
> initialized before it is used.  (Either by some sort of init function
> or maybe a compiler flag to force into .bss?)
> 
reading the c/c++ standard might help, too.

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.




More information about the kde-core-devel mailing list