Nathan Hjelm wrote:
> On Jan 20, 2014, at 4:56 PM, Tim Roberts <t...@probo.com> wrote:
>
>> Even if there isn't, the standard guarantees that those two constructs
>> are identical.  Any elements that don't have initializer values get zeroed.
> Not quite. This is true for global/static variables. Anything allocated on 
> the stack that is not explicitly initialized gets whatever was on already the 
> stack.

Sorry, but this is incorrect.  What you say is true if I omit the
initializer list completely.  But if I provide a PARTIAL initializer
list, then the rest of the structure is zeroed, regardless of the
storage class.

*C99 Standard 6.7.8.21*

    If there are fewer initializers in a brace-enclosed list than there
    are elements or members of an aggregate, or fewer characters in a
    string literal used to initialize an array of known size than there
    are elements in the array, the remainder of the aggregate shall be
    initialized implicitly the same as objects that have static storage
    duration.


C++ words it a little differently, but the concept is the same.  You can
always use this to zero-initialize a structure or array:

   some_struct s = {0};

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to