Moving some macros.

This commit is contained in:
David Williams 2015-05-08 14:50:10 +02:00
parent f16a247934
commit 64c30044b0
4 changed files with 22 additions and 16 deletions

View File

@ -24,6 +24,7 @@ distribution.
#ifndef __PolyVox_Array_H__ #ifndef __PolyVox_Array_H__
#define __PolyVox_Array_H__ #define __PolyVox_Array_H__
#include <PolyVox/Impl/Typedef.h>
#include <PolyVox/Impl/ErrorHandling.h> #include <PolyVox/Impl/ErrorHandling.h>
#include <cstdint> #include <cstdint>

View File

@ -35,19 +35,6 @@ freely, subject to the following restrictions:
#include <string.h> // Exception constuctors take strings. #include <string.h> // Exception constuctors take strings.
#include <csignal> #include <csignal>
#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 // 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 // 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. // 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 #define POLYVOX_MSC_WARNING_POP
#endif #endif
#define POLYVOX_UNUSED(x) do { (void)sizeof(x); } while(0)
/* /*
* Assertions * Assertions
* ---------- * ----------

View File

@ -91,7 +91,7 @@ namespace PolyVox
{ {
std::ostringstream oss; std::ostringstream oss;
int a[] = { 0, ((void)(oss << args), 0) ... }; 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(); return oss.str();
} }

View File

@ -71,4 +71,24 @@ freely, subject to the following restrictions:
#define POLYVOX_LOCAL #define POLYVOX_LOCAL
#endif // POLYVOX_SHARED #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 #endif