diff options
author | Wan-Teh Chang <wtc@google.com> | 2021-09-10 15:54:51 -0700 |
---|---|---|
committer | Jerome Jiang <jianj@google.com> | 2021-09-27 15:17:19 -0700 |
commit | 5df4195b43e5b69572cdb1903d67d6f6c2917285 (patch) | |
tree | 6e6b39826834f4d0da21f64cf8609cb00087a4e8 | |
parent | 15a75b45304248f746634b43763c496322bf8968 (diff) | |
download | libvpx-5df4195b43e5b69572cdb1903d67d6f6c2917285.tar.gz |
Define the VPX_NO_RETURN macro for MSVC
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.
Change-Id: Id9bb0077e2a4f16ec2ca9c913dd93673a0e385cf
(cherry picked from commit 8a6fbc0b4eb8538e213782bcdc3969a08b44e73b)
-rw-r--r-- | args.c | 6 | ||||
-rw-r--r-- | tools_common.h | 10 |
2 files changed, 10 insertions, 6 deletions
@@ -16,8 +16,10 @@ #include "vpx/vpx_integer.h" #include "vpx_ports/msvc.h" -#if defined(__GNUC__) && __GNUC__ -extern void die(const char *fmt, ...) __attribute__((noreturn)); +#if defined(__GNUC__) +__attribute__((noreturn)) extern void die(const char *fmt, ...); +#elif defined(_MSC_VER) +__declspec(noreturn) extern void die(const char *fmt, ...); #else extern void die(const char *fmt, ...); #endif diff --git a/tools_common.h b/tools_common.h index 4526d9f16..4e8851fc1 100644 --- a/tools_common.h +++ b/tools_common.h @@ -110,6 +110,8 @@ extern "C" { #if defined(__GNUC__) #define VPX_NO_RETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define VPX_NO_RETURN __declspec(noreturn) #else #define VPX_NO_RETURN #endif @@ -117,14 +119,14 @@ extern "C" { /* Sets a stdio stream into binary mode */ FILE *set_binary_mode(FILE *stream); -void die(const char *fmt, ...) VPX_NO_RETURN; -void fatal(const char *fmt, ...) VPX_NO_RETURN; +VPX_NO_RETURN void die(const char *fmt, ...); +VPX_NO_RETURN void fatal(const char *fmt, ...); void warn(const char *fmt, ...); -void die_codec(vpx_codec_ctx_t *ctx, const char *s) VPX_NO_RETURN; +VPX_NO_RETURN void die_codec(vpx_codec_ctx_t *ctx, const char *s); /* The tool including this file must define usage_exit() */ -void usage_exit(void) VPX_NO_RETURN; +VPX_NO_RETURN void usage_exit(void); #undef VPX_NO_RETURN |