1
0

Fixed UNUSED macro so that it doesn't require type knowledge.

Introduced new UNUSED_VAR macro that is used when type knowledge is available (for local variables).
This commit is contained in:
madmaxoft 2014-09-26 22:53:11 +02:00
parent a817243e3f
commit 0d83477540
2 changed files with 14 additions and 5 deletions

View File

@ -162,8 +162,17 @@ template class SizeChecker<UInt16, 2>;
TypeName(const TypeName &); \ TypeName(const TypeName &); \
void operator =(const TypeName &) void operator =(const TypeName &)
// A macro that is used to mark unused local variables, to avoid pedantic warnings in gcc / clang / MSVC
// Note that in MSVC it requires the full type of X to be known
#define UNUSED_VAR(X) (void)(X)
// A macro that is used to mark unused function parameters, to avoid pedantic warnings in gcc // A macro that is used to mark unused function parameters, to avoid pedantic warnings in gcc
#define UNUSED(X) (void)(X) // Written so that the full type of param needn't be known
#ifdef _MSC_VER
#define UNUSED(X)
#else
#define UNUSED UNUSED_VAR
#endif

View File

@ -213,8 +213,8 @@ public:
// If your platform produces a compiler error here, you'll need to add code that manually decodes 32-bit floats // If your platform produces a compiler error here, you'll need to add code that manually decodes 32-bit floats
char Check1[5 - sizeof(float)]; // Fails if sizeof(float) > 4 char Check1[5 - sizeof(float)]; // Fails if sizeof(float) > 4
char Check2[sizeof(float) - 3]; // Fails if sizeof(float) < 4 char Check2[sizeof(float) - 3]; // Fails if sizeof(float) < 4
UNUSED(Check1); UNUSED_VAR(Check1);
UNUSED(Check2); UNUSED_VAR(Check2);
Int32 i = GetBEInt(m_Data + m_Tags[(size_t)a_Tag].m_DataStart); Int32 i = GetBEInt(m_Data + m_Tags[(size_t)a_Tag].m_DataStart);
float f; float f;
@ -229,8 +229,8 @@ public:
// If your platform produces a compiler error here, you'll need to add code that manually decodes 64-bit doubles // If your platform produces a compiler error here, you'll need to add code that manually decodes 64-bit doubles
char Check1[9 - sizeof(double)]; // Fails if sizeof(double) > 8 char Check1[9 - sizeof(double)]; // Fails if sizeof(double) > 8
char Check2[sizeof(double) - 7]; // Fails if sizeof(double) < 8 char Check2[sizeof(double) - 7]; // Fails if sizeof(double) < 8
UNUSED(Check1); UNUSED_VAR(Check1);
UNUSED(Check2); UNUSED_VAR(Check2);
ASSERT(m_Tags[(size_t)a_Tag].m_Type == TAG_Double); ASSERT(m_Tags[(size_t)a_Tag].m_Type == TAG_Double);
return NetworkToHostDouble8(m_Data + m_Tags[(size_t)a_Tag].m_DataStart); return NetworkToHostDouble8(m_Data + m_Tags[(size_t)a_Tag].m_DataStart);