Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPhil Nash2014-05-13 17:48:47 +0100
committerPhil Nash2014-05-13 17:48:47 +0100
commitad4489043b1d45476e0bdcfc046f4b8b15e1cbce (patch)
tree15d1d4ff38412b41ec6de5addc570be09eca8b6c /include
parent4e044ed4b17eb7c691b757fc45ec071b1848b6e0 (diff)
downloadcatch3-ad4489043b1d45476e0bdcfc046f4b8b15e1cbce.tar.gz
Unanonymised unions to avoid breaking on compilers that don’t support them
- e.g. GCC 4.3 and 4.4 - fixes #281
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_tostring.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/include/internal/catch_tostring.h b/include/internal/catch_tostring.h
index d6c2fcf2..25faa2a3 100644
--- a/include/internal/catch_tostring.h
+++ b/include/internal/catch_tostring.h
@@ -84,25 +84,25 @@ namespace Detail {
enum Arch { Big, Little };
static Arch which() {
- union {
+ union _{
int asInt;
char asChar[sizeof (int)];
- };
+ } u;
- asInt = 1;
- return ( asChar[sizeof(int)-1] == 1 ) ? Big : Little;
+ u.asInt = 1;
+ return ( u.asChar[sizeof(int)-1] == 1 ) ? Big : Little;
}
};
// Writes the raw memory into a string, considering endianness
template<typename T>
std::string rawMemoryToString( T value ) {
- union {
+ union _ {
T typedValue;
unsigned char bytes[sizeof(T)];
- };
+ } u;
- typedValue = value;
+ u.typedValue = value;
std::ostringstream oss;
oss << "0x";
@@ -113,7 +113,7 @@ namespace Detail {
end = inc = -1;
}
for( ; i != end; i += inc )
- oss << std::hex << std::setw(2) << std::setfill('0') << (unsigned int)bytes[i];
+ oss << std::hex << std::setw(2) << std::setfill('0') << (unsigned int)u.bytes[i];
return oss.str();
}