Document: N1289
Date: 2008/03/12
Author: Franklin

As I understand it from our conversation, here is the current situation in the ANSI C and C++ standards with respect to anonymous structs and unions:

       
ANSI C++ anonymous unions:YES
ANSI C++ anonymous structs:NO
ANSI C anonymous unions:NO
ANSI C anonymous unions:NO
   

If the above is in fact correct, then let me make two arguments:

  1. Insofar as it is desirable to minimize the differences between ANSI C and ANSI C++, either ANSI C should adopt anonymous unions or ANSI C++ should deprecate or delete them.  I prefer the former.  They are sometimes useful and seem to be harmless to non-users.  
  2. Insofar as it is desirable to have structs and unions behave consistently where they are similar, it seems to me that the major difference between structs and unions is the offsets (overlapping or non-overlapping) of their members.  This has absolutely NOTHING to do with naming, ergo, if anonymous unions are permitted, it follows that anonymous structs should be permitted too.  They have the (same) obvious meaning, and the existing standard language for unions can presumably reused for structs – or one could use the concept “aggregates” for both.  But if C++ follows this logic and adds anonymous structs, then mutatis mutandis, so should C.  QED.
  3.  
Anyway, I would personally all four of them useful in my C and C++ programming.