Note that there are some explanatory texts on larger screens.

plurals
  1. POAre "anonymous structs" standard? And, really, what *are* they?
    primarykey
    data
    text
    <p>MSDN <a href="http://msdn.microsoft.com/en-us/library/z2cx9y4f.aspx" rel="noreferrer">reckons</a> that anonymous structs are non-standard in C++:</p> <blockquote> <p>A Microsoft C extension allows you to declare a structure variable within another structure without giving it a name. These nested structures are called anonymous structures. C++ does not allow anonymous structures.</p> <p>You can access the members of an anonymous structure as if they were members in the containing structure.</p> </blockquote> <p><a href="https://stackoverflow.com/questions/14187647/c-private-modifier-ignored-on-nested-anonymous-struct#comment19665939_14187647"><em>@K-ballo</em> agrees</a>.</p> <p>I'm told that this feature isn't necessarily the same as just creating an unnamed struct but I can't see a distinction in terms of standard wording.</p> <p>C++11 says:</p> <blockquote> <p><code>[C++11: 9/1]</code>: <em>[..]</em> A <em>class-specifier</em> whose <em>class-head</em> omits the <em>class-head-name</em> defines an unnamed class.</p> </blockquote> <p>and provides an entire grammatical construction for a type definition missing a name.</p> <p>C++03 lacks this explicit wording, but similarly indicates that the <code>identifier</code> in a type definition is optional, and makes reference to "unnamed classes" in <code>9.4.2/5</code> and <code>3.5/4</code>.</p> <ul> <li>So is MSDN wrong, and these things are all completely standard?</li> <li>Or is there some subtlety I'm missing between "unnamed structs/classes" and the same when used as members that prevents them from being covered by this C++03/C++11 functionality?</li> <li>Am I missing some fundamental difference between "unnamed struct" and "anonymous struct"? They look like synonyms to me.</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload