Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solaris, integer.cpp and "Types cannot be declared in anonymous union" #274

Closed
noloader opened this issue Sep 15, 2016 · 1 comment
Closed

Comments

@noloader
Copy link
Collaborator

noloader commented Sep 15, 2016

Testing under Solaris 11.3 is revealing:

[  3%] Building CXX object CMakeFiles/cryptopp-object.dir/integer.cpp.o
/opt/solarisstudio12.3/bin/CC -fPIC -native -m64 -template=no%extdef -o CMakeFiles/cryptopp-object.dir/integer.cpp.o
-c /export/home/jwalton/cryptopp/integer.cpp
CC: Warning: -xchip=native detection failed, falling back to -xchip=generic
"/export/home/jwalton/cryptopp/integer.cpp", line 335: Warning: Types cannot be declared in anonymous union.
1 Warning(s) detected.

According to the Microsoft docs at Anonymous Unions:

Simply omitting the class-name portion of the syntax does not make a union an anonymous union. For a union to qualify as an anonymous union, the declaration must not declare an object.

I think we are getting into trouble because we are declaring class objects (i.e., objects of type m_halfs). That's what the SunCC compiler is complaining about.

Also see SunCC 5.12 through 5.14 and “Types cannot be declared in anonymous union”. Its our question for this issue. A related question is Why does C++ disallow anonymous structs and unions? on Stack Overflow, but its not our question.


I'm guessing the cod below is very old with a MSVC pedigree. It probably dates back to the late 1990s.

union
{
#ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE
    dword m_whole;
#endif
    struct
    {
    #ifdef IS_LITTLE_ENDIAN
        word low;
        word high;
    #else
        word high;
        word low;
    #endif
    } m_halfs;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant