avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Strange problem - Pointer not null when declared


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Strange problem - Pointer not null when declared
Date: Tue, 31 Jul 2007 20:33:17 +0200 (MET DST)

Colin Paul Gloster <address@hidden> wrote:

> C does not guarantee an initial value for something which is
> declared without a definition.

First, you are obviously confusing "definition" with "initializer".

Second, this is wrong: all objects with static storage (i.e.
everything explicitly declared "static", as well as all global
objects) are guaranteed to be initialized to integer 0, a null
pointer, or floating-point 0.0, respectively, depending on their
data type.

Russell's answer was the correct one: automatic variables (i.e.  those
declared inside a function without the "static" keyword) start out
with random values, and explicitly need an initializer in order to
have determined values.  Note that their initializers are effectively
assignment statements executed each time you enter the block; so you
could as well use explicit assignments for those parts of a structure
you are really interested in, and leave the remainder random.

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]