diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | alc/alc.cpp | 3 | ||||
-rw-r--r-- | common/almalloc.h | 23 | ||||
-rw-r--r-- | common/pragmadefs.h | 21 |
4 files changed, 28 insertions, 20 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 03c60162..9cc0c6fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -551,6 +551,7 @@ SET(COMMON_OBJS common/intrusive_ptr.h common/math_defs.h common/opthelpers.h + common/pragmadefs.h common/strutils.cpp common/strutils.h common/threads.cpp diff --git a/alc/alc.cpp b/alc/alc.cpp index 792ead3e..119067fd 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -86,6 +86,7 @@ #include "logging.h" #include "mastering.h" #include "opthelpers.h" +#include "pragmadefs.h" #include "ringbuffer.h" #include "strutils.h" #include "threads.h" @@ -915,7 +916,7 @@ constexpr ALCint alcEFXMinorVersion = 0; * zero objects here, so silence that. */ DIAGNOSTIC_PUSH -MVSDIAGNOSTIC(warning(disable : 4815)) +msc_pragma(warning(disable : 4815)) al::FlexArray<ALCcontext*> EmptyContextArray{0u}; DIAGNOSTIC_POP diff --git a/common/almalloc.h b/common/almalloc.h index b844e5fc..15ec600d 100644 --- a/common/almalloc.h +++ b/common/almalloc.h @@ -10,23 +10,8 @@ #include <type_traits> #include <utility> +#include "pragmadefs.h" -#ifdef _MSC_VER -#define DIAGNOSTIC_PUSH __pragma(warning(push)) -#define GNUDIAGNOSTIC(x) -#define MVSDIAGNOSTIC(...) __pragma(__VA_ARGS__) -#define DIAGNOSTIC_POP __pragma(warning(pop)) -#elif defined(__GNUC__) || defined(__clang__) -#define DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") -#define GNUDIAGNOSTIC(x) _Pragma(x) -#define MVSDIAGNOSTIC(...) -#define DIAGNOSTIC_POP _Pragma("GCC diagnostic push") -#else -#define DIAGNOSTIC_PUSH -#define GNUDIAGNOSTIC(x) -#define MVSDIAGNOSTIC(...) -#define DIAGNOSTIC_POP -#endif void *al_malloc(size_t alignment, size_t size); void *al_calloc(size_t alignment, size_t size); @@ -119,7 +104,7 @@ inline T* assume_aligned(T *ptr) noexcept * destructor is trivial (a no-op). So disable that warning for this call. */ DIAGNOSTIC_PUSH -MVSDIAGNOSTIC(warning(disable : 4100)) +msc_pragma(warning(disable : 4100)) template<typename T> inline void destroy_at(T *ptr) { ptr->~T(); } DIAGNOSTIC_POP @@ -263,8 +248,8 @@ struct FlexArray { const index_type mSize; DIAGNOSTIC_PUSH -GNUDIAGNOSTIC("GCC diagnostic ignored \"-Wpedantic\"") -MVSDIAGNOSTIC(warning(disable : 4200)) +std_pragma("GCC diagnostic ignored \"-Wpedantic\"") +msc_pragma(warning(disable : 4200)) alignas(alignment) element_type mArray[0]; DIAGNOSTIC_POP diff --git a/common/pragmadefs.h b/common/pragmadefs.h new file mode 100644 index 00000000..1d0af066 --- /dev/null +++ b/common/pragmadefs.h @@ -0,0 +1,21 @@ +#ifndef PRAGMADEFS_H +#define PRAGMADEFS_H + +#if defined(_MSC_VER) +#define DIAGNOSTIC_PUSH __pragma(warning(push)) +#define DIAGNOSTIC_POP __pragma(warning(pop)) +#define std_pragma(...) +#define msc_pragma __pragma +#else +#if defined(__GNUC__) || defined(__clang__) +#define DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") +#define DIAGNOSTIC_POP _Pragma("GCC diagnostic push") +#else +#define DIAGNOSTIC_PUSH +#define DIAGNOSTIC_POP +#endif +#define std_pragma _Pragma +#define msc_pragma(...) +#endif + +#endif /* PRAGMADEFS_H */ |