title: g++ compiling C++11 using -Wpedantic option: Is there an option to disable only the warning about unnamed structs?
body: <p>I want to keep any other checks <code>-Wpedantic</code> does but lose the warning about unnamed structs <code>error: ISO C++ prohibits anonymous structs [-Wpedantic]</code>.</p>
  
  <p>I want to be able to do the following:</p>
  
  <pre><code>union
  {
    struct
    {
      float x, y, z, w;
    };
    struct
    {
      float r, g, b, a;
    };
  
    float v[4];
  };
  </code></pre>
  
  <hr>
  
  <h2>What I've found so far</h2>
  
  <p>I'm using C++11 and compiling with the <code>-std=c++11</code> flag. I've <a href="https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html" rel="noreferrer">read that C11 supports this feature</a>, but I haven't seen any mention of it being supported in C++11.</p>
  
  <p>I've come across mention of <code>-fms-extensions</code>:</p>
  
  <ul>
  <li><p><a href="https://stackoverflow.com/a/2391089/2507444">In this SO question about <strong>C</strong> for which it is the accepted answer</a></p></li>
  <li><p><a href="https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options" rel="noreferrer">In the GCC documentation for the flag's use when compiling C++ which doesn't give very many details</a></p></li>
  </ul>
  
  <p>I tried the flag and it doesn't appear to have any effect (no matter the permutation of ordering between <code>-fms-extensions</code> and <code>-Wpedantic</code>).</p>
  
  <h2>EDIT - More details</h2>
  
  <p>Thanks to the comments I've found the following:</p>
  
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/13138605/why-class-int-i-is-not-fully-standard-conformant">Details about why unnamed classes/structs are not fully conformant with the standard</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/2253878/why-does-c-disallow-anonymous-structs-and-unions">A post that claims my example code relies on undefined behavior</a></p></li>
  </ul>
  
  <p>I'd still like to know if there is a method of enabling this gcc extension (which all compilers I know of have) that will disable the warning. Or is <code>-Wpedantic</code> all or nothing?</p>