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 | #include "vpx/vpx_integer.h" | 16 | #include "vpx/vpx_integer.h" |
| 17 | #include "vpx_ports/msvc.h" | 17 | #include "vpx_ports/msvc.h" |
| 18 | 18 | ||
| 19 | #if defined(__GNUC__) && __GNUC__ | 19 | #if defined(__GNUC__) |
| 20 | extern void die(const char *fmt, ...) __attribute__((noreturn)); | 20 | __attribute__((noreturn)) extern void die(const char *fmt, ...); |
| 21 | #elif defined(_MSC_VER) | ||
| 22 | __declspec(noreturn) extern void die(const char *fmt, ...); | ||
| 21 | #else | 23 | #else |
| 22 | extern void die(const char *fmt, ...); | 24 | extern void die(const char *fmt, ...); |
| 23 | #endif | 25 | #endif |
| @@ -110,6 +110,8 @@ extern "C" { · 109 unmodified lines | |||
| 110 | 110 | ||
| 111 | #if defined(__GNUC__) | 111 | #if defined(__GNUC__) |
| 112 | #define VPX_NO_RETURN __attribute__((noreturn)) | 112 | #define VPX_NO_RETURN __attribute__((noreturn)) |
| 113 | #elif defined(_MSC_VER) | ||
| 114 | #define VPX_NO_RETURN __declspec(noreturn) | ||
| 113 | #else | 115 | #else |
| 114 | #define VPX_NO_RETURN | 116 | #define VPX_NO_RETURN |
| 115 | #endif | 117 | #endif |
| @@ -117,14 +119,14 @@ extern "C" { · 1 unmodified line | |||
| 117 | /* Sets a stdio stream into binary mode */ | 119 | /* Sets a stdio stream into binary mode */ |
| 118 | FILE *set_binary_mode(FILE *stream); | 120 | FILE *set_binary_mode(FILE *stream); |
| 119 | 121 | ||
| 120 | void die(const char *fmt, ...) VPX_NO_RETURN; | 122 | VPX_NO_RETURN void die(const char *fmt, ...); |
| 121 | void fatal(const char *fmt, ...) VPX_NO_RETURN; | 123 | VPX_NO_RETURN void fatal(const char *fmt, ...); |
| 122 | void warn(const char *fmt, ...); | 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 | /* The tool including this file must define usage_exit() */ | 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 | #undef VPX_NO_RETURN | 131 | #undef VPX_NO_RETURN |
| 130 | 132 | ||