Apache OpenOffice (AOO) Bugzilla – Issue 97325
WaE: Warning: Types cannot be declared in anonymous union.
Last modified: 2017-05-20 11:33:34 UTC
New compiler warning (SunStudio12) breaks build (because of WaE): "Warning: Types cannot be declared in anonymous union." Happens in "sc/inc/refdata.hxx", union declared in line 81. I looked it up, and yes, the compiler is right about the warning as far as the standard is concerned. A possible solution would be to give the union a name, but this requires a number of changes all over the place. Unfortunately this header is included in a number of source files, so I decided to disable the warning globally. Please remove the warning tag "anonnotype" from the -erroff list in solenv/inc/unxsols4.mk when this issue is done.
Created attachment 58877 [details] potential simple fix?
Might do. However, do I understand this correctly that the problem is BOOL which is typedef sal_Bool BOOL; an using directly a POD such as unsigned char instead would not give this warning? Theoretically, using BOOL is questionable anyway and works only if the type is capable of holding at least 8 bits.. which also isn't guaranteed for unsigned char. If the problem is the typedef then also using sal_uInt8 would not do and we have to use the approach the attached patch takes.
@er: the problem is not some typedef but the struct declaration inside the anonymous union (IIUC)
Ah, I see, was mislead. I wonder though why that should not be allowed. @hr: sc/inc/compiler.hxx has similar union{struct{}} in ScDoubleRawToken and ScRawToken, didn't that break as well?
@er: yup, same warning in sc/inc/compiler.hxx line 133 and 158.
From the ISO C++ standard (ISO/IEC 14882:1998(E) -- C++ -- Classes): -- snip -- -2- A union of the form union { member-specification } ; is called an anonymous union; it defines an unnamed object of unnamed type. The member-specification of an anonymous union shall only define non-static data members. [Note: nested types and functions cannot be declared within an anonymous union. ] -- snip -- The note in the standard clarifies that an anonymous union can't have nested types. I guess it has something to do with storage classes ...
Reset assigne to the default "issues@openoffice.apache.org".