Define VPX_NO_RETURN as __declspec(noreturn) for MSVC. See https://docs.microsoft.com/en-us/cpp/cpp/noreturn?view=msvc-160 This requires moving VPX_NO_RETURN before function declarations because __declspec(noreturn) must be placed there. Fortunately GCC's __attribute__((noreturn)) can be placed either before or after function declarations.
Unified · Split
| @@ -16,8 +16,10 @@ · 15 unmodified lines | ||
| 16 | 16 | #include "vpx/vpx_integer.h" |
| 17 | 17 | #include "vpx_ports/msvc.h" |
| 18 | 18 | |
| 19 | −#if defined(__GNUC__) && __GNUC__ | |
| 20 | −extern void die(const char *fmt, ...) __attribute__((noreturn)); | |
| 19 | +#if defined(__GNUC__) | |
| 20 | +__attribute__((noreturn)) extern void die(const char *fmt, ...); | |
| 21 | +#elif defined(_MSC_VER) | |
| 22 | +__declspec(noreturn) extern void die(const char *fmt, ...); | |
| 21 | 23 | #else |
| 22 | 24 | extern void die(const char *fmt, ...); |
| 23 | 25 | #endif |
| @@ -110,6 +110,8 @@ extern "C" { · 109 unmodified lines | ||
| 110 | 110 | |
| 111 | 111 | #if defined(__GNUC__) |
| 112 | 112 | #define VPX_NO_RETURN __attribute__((noreturn)) |
| 113 | +#elif defined(_MSC_VER) | |
| 114 | +#define VPX_NO_RETURN __declspec(noreturn) | |
| 113 | 115 | #else |
| 114 | 116 | #define VPX_NO_RETURN |
| 115 | 117 | #endif |
| @@ -117,14 +119,14 @@ extern "C" { · 1 unmodified line | ||
| 117 | 119 | /* Sets a stdio stream into binary mode */ |
| 118 | 120 | FILE *set_binary_mode(FILE *stream); |
| 119 | 121 | |
| 120 | −void die(const char *fmt, ...) VPX_NO_RETURN; | |
| 121 | −void fatal(const char *fmt, ...) VPX_NO_RETURN; | |
| 122 | +VPX_NO_RETURN void die(const char *fmt, ...); | |
| 123 | +VPX_NO_RETURN void fatal(const char *fmt, ...); | |
| 122 | 124 | void warn(const char *fmt, ...); |
| 123 | 125 | |
| 124 | −void die_codec(vpx_codec_ctx_t *ctx, const char *s) VPX_NO_RETURN; | |
| 126 | +VPX_NO_RETURN void die_codec(vpx_codec_ctx_t *ctx, const char *s); | |
| 125 | 127 | |
| 126 | 128 | /* The tool including this file must define usage_exit() */ |
| 127 | −void usage_exit(void) VPX_NO_RETURN; | |
| 129 | +VPX_NO_RETURN void usage_exit(void); | |
| 128 | 130 | |
| 129 | 131 | #undef VPX_NO_RETURN |
| 130 | 132 | |