From f2e5149319e4ed4a86c9f5e3f3bef1b89d06cd19 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Thu, 15 Sep 2016 09:38:40 -0400 Subject: [PATCH] Cleared "Types cannot be declared in anonymous union" (Issue 274) Thanks to Martin Bonner at http://stackoverflow.com/a/39507183 --- integer.cpp | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/integer.cpp b/integer.cpp index 671852dd..bb41088f 100644 --- a/integer.cpp +++ b/integer.cpp @@ -317,22 +317,26 @@ public: word GetHighHalfAsBorrow() const {return 0-m_halfs.high;} private: - 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; - }; + // Issue 274, "Types cannot be declared in anonymous union", + // http://github.com/weidai11/cryptopp/issues/274 + // Thanks to Martin Bonner at http://stackoverflow.com/a/39507183 + struct half_words + { + #ifdef IS_LITTLE_ENDIAN + word low; + word high; + #else + word high; + word low; + #endif + }; + union + { + #ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE + dword m_whole; + #endif + half_words m_halfs; + }; }; class Word