diff --git a/include/PolyVox/Array.h b/include/PolyVox/Array.h index 2a34bc4f..82458af1 100644 --- a/include/PolyVox/Array.h +++ b/include/PolyVox/Array.h @@ -24,6 +24,7 @@ distribution. #ifndef __PolyVox_Array_H__ #define __PolyVox_Array_H__ +#include #include #include diff --git a/include/PolyVox/Impl/ErrorHandling.h b/include/PolyVox/Impl/ErrorHandling.h index 5e174546..5b9544f9 100644 --- a/include/PolyVox/Impl/ErrorHandling.h +++ b/include/PolyVox/Impl/ErrorHandling.h @@ -35,19 +35,6 @@ freely, subject to the following restrictions: #include // Exception constuctors take strings. #include -#if defined(_MSC_VER) - // In Visual Studio we can use this function to go into the debugger. - #define POLYVOX_HALT() __debugbreak() -#else - // On other platforms we just halt by forcing a crash. - // Hopefully this puts us in the debugger if one is running - #if defined(__linux__) || defined(__APPLE__) - #define POLYVOX_HALT() raise(SIGTRAP) - #else - #define POLYVOX_HALT() *((unsigned int*)0) = 0xDEAD - #endif -#endif - // Macros cannot contain #ifdefs, but some of our macros need to disable warnings and such warning supression is // platform specific. But macros can contain other macros, so we create macros to control the warnings and use // those instead. This set of warning supression macros can be extended to GCC/Clang when required. @@ -61,8 +48,6 @@ freely, subject to the following restrictions: #define POLYVOX_MSC_WARNING_POP #endif -#define POLYVOX_UNUSED(x) do { (void)sizeof(x); } while(0) - /* * Assertions * ---------- diff --git a/include/PolyVox/Impl/Logging.h b/include/PolyVox/Impl/Logging.h index 0f887d2f..3d270c25 100644 --- a/include/PolyVox/Impl/Logging.h +++ b/include/PolyVox/Impl/Logging.h @@ -91,7 +91,7 @@ namespace PolyVox { std::ostringstream oss; int a[] = { 0, ((void)(oss << args), 0) ... }; - (void)a; // Prevent warnings about unused param + (void)a; // POLYVOX_UNUSED() doesn't seem to work here? return oss.str(); } diff --git a/include/PolyVox/Impl/TypeDef.h b/include/PolyVox/Impl/TypeDef.h index f9ac641e..63fd18b3 100644 --- a/include/PolyVox/Impl/TypeDef.h +++ b/include/PolyVox/Impl/TypeDef.h @@ -71,4 +71,24 @@ freely, subject to the following restrictions: #define POLYVOX_LOCAL #endif // POLYVOX_SHARED +#if defined(_MSC_VER) + // In Visual Studio we can use this function to go into the debugger. + #define POLYVOX_HALT() __debugbreak() +#else + // On other platforms we just halt by forcing a crash. + // Hopefully this puts us in the debugger if one is running + #if defined(__linux__) || defined(__APPLE__) + #define POLYVOX_HALT() raise(SIGTRAP) + #else + #define POLYVOX_HALT() *((unsigned int*)0) = 0xDEAD + #endif +#endif + +// Used to prevent the compiler complaining about unused varuables, particularly useful when +// e.g. asserts are disabled and the parameter it was checking isn't used anywhere else. +// Note that this implementation doesn't seem to work everywhere, for some reason I have +// seen it give compile errors when combined with variadic template functions (to be confirmed)? +// Implementation from here: http://stackoverflow.com/a/4851173/2337254 +#define POLYVOX_UNUSED(x) do { (void)sizeof(x); } while(0) + #endif