| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
|
|
| #ifndef SPIRV_CROSS_ERROR_HANDLING |
| #define SPIRV_CROSS_ERROR_HANDLING |
|
|
| #include <stdio.h> |
| #include <stdlib.h> |
| #include <string> |
| #ifndef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS |
| #include <stdexcept> |
| #endif |
|
|
| #ifdef SPIRV_CROSS_NAMESPACE_OVERRIDE |
| #define SPIRV_CROSS_NAMESPACE SPIRV_CROSS_NAMESPACE_OVERRIDE |
| #else |
| #define SPIRV_CROSS_NAMESPACE spirv_cross |
| #endif |
|
|
| namespace SPIRV_CROSS_NAMESPACE |
| { |
| #ifdef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS |
| #if !defined(_MSC_VER) || defined(__clang__) |
| [[noreturn]] |
| #elif defined(_MSC_VER) |
| __declspec(noreturn) |
| #endif |
| inline void |
| report_and_abort(const std::string &msg) |
| { |
| #ifdef NDEBUG |
| (void)msg; |
| #else |
| fprintf(stderr, "There was a compiler error: %s\n", msg.c_str()); |
| #endif |
| fflush(stderr); |
| abort(); |
| } |
|
|
| #define SPIRV_CROSS_THROW(x) report_and_abort(x) |
| #else |
| class CompilerError : public std::runtime_error |
| { |
| public: |
| explicit CompilerError(const std::string &str) |
| : std::runtime_error(str) |
| { |
| } |
|
|
| explicit CompilerError(const char *str) |
| : std::runtime_error(str) |
| { |
| } |
| }; |
|
|
| #define SPIRV_CROSS_THROW(x) throw CompilerError(x) |
| #endif |
|
|
| |
| |
| |
| #if defined(_MSC_VER) && _MSC_VER < 1900 |
| #define SPIRV_CROSS_NOEXCEPT |
| #else |
| #define SPIRV_CROSS_NOEXCEPT noexcept |
| #endif |
|
|
| #if __cplusplus >= 201402l |
| #define SPIRV_CROSS_DEPRECATED(reason) [[deprecated(reason)]] |
| #elif defined(__GNUC__) |
| #define SPIRV_CROSS_DEPRECATED(reason) __attribute__((deprecated)) |
| #elif defined(_MSC_VER) |
| #define SPIRV_CROSS_DEPRECATED(reason) __declspec(deprecated(reason)) |
| #else |
| #define SPIRV_CROSS_DEPRECATED(reason) |
| #endif |
| } |
|
|
| #endif |
|
|