On Jan 21, 2014, at 10:30 AM, Tim Roberts <t...@probo.com> wrote:
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.
Ah. Ok. Wasn't aware of that case. The code is question is ISO C89 to support MSVC. Do you know if the C89 standard also guarantees the rest of the struct is zeroed?
-Nathan
------------------------------------------------------------------------------ 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