diff --git a/common/compiler_macros.h b/common/compiler_macros.h new file mode 100644 index 000000000..16088a405 --- /dev/null +++ b/common/compiler_macros.h @@ -0,0 +1,20 @@ +#pragma once + +#if defined(_MSC_VER) + #define PUSH_DISABLE_DEPRECATED_WARNINGS() __pragma(warning(push)) \ + __pragma(warning(disable:4996)) + #define POP_DISABLE_DEPRECATED_WARNINGS() __pragma(warning(pop)) +#elif defined(__GNUC__) || defined(__clang__) + #define PUSH_DISABLE_DEPRECATED_WARNINGS() _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") + #define POP_DISABLE_DEPRECATED_WARNINGS() _Pragma("GCC diagnostic pop") +#else + #define PUSH_DISABLE_DEPRECATED_WARNINGS() + #define POP_DISABLE_DEPRECATED_WARNINGS() +#endif + +#if defined(_MSC_VER) && !defined(__clang__) + #define UNREACHABLE() __assume(0) +#else + #define UNREACHABLE() __builtin_unreachable() +#endif \ No newline at end of file