[collectd] Question about static initialization

Sebastian Harl sh at tokkee.org
Thu Aug 14 11:38:58 CEST 2008


Hi Peter,

On Thu, Aug 14, 2008 at 11:25:14AM +0200, Peter Holik wrote:
> Is this not common to all comilers that a static declared variable
> is automatically initialized to 0?

The C99 standard requires (and I'm pretty sure that earlier C standards
did so as well) that static integer values are initialized to zero
(section 6.7.8). So all standard compliant compiler _must_ do that.

> instead of
> 
> static int c_ipmi_active = 0;
> 
> i write
> 
> static int c_ipmi_active;

That's perfectly find. I usually prefer to state things explicitly to
make things clear though. That's just a matter of personal taste.

Cheers,
Sebastian

-- 
Sebastian "tokkee" Harl +++ GnuPG-ID: 0x8501C7FC +++ http://tokkee.org/

Those who would give up Essential Liberty to purchase a little Temporary
Safety, deserve neither Liberty nor Safety.         -- Benjamin Franklin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20080814/150b4b5f/attachment.pgp 


More information about the collectd mailing list