Can Q_GLOBAL_STATIC replace KStaticDelete ?
Stefan Teleman
stefan.teleman at gmail.com
Tue Jan 23 15:20:28 GMT 2007
On Tuesday 23 January 2007 03:16, Oswald Buddenhagen wrote:
> 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.
Thus Spoke Bjarne Stroustroup:
"Resource Acquisition Is Initialization".
:-)
--Stefan
--
Stefan Teleman 'Nobody Expects the Spanish Inquisition'
KDE e.V. -Monty Python
stefan.teleman at gmail.com
More information about the kde-core-devel
mailing list