History

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.

Wan-Teh Chang committed 5 years ago

Commit 8a6fbc01 parent 65a17512 files · +10 −6Browse files

Unified · Split

2 files
  1. args.c +4 −2
  2. tools_common.h +6 −4
args.c+4−2
@@ -16,8 +16,10 @@ · 15 unmodified lines
1616 #include "vpx/vpx_integer.h"
1717 #include "vpx_ports/msvc.h"
1818
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, ...);
2123 #else
2224 extern void die(const char *fmt, ...);
2325 #endif
tools_common.h+6−4
@@ -110,6 +110,8 @@ extern "C" { · 109 unmodified lines
110110
111111 #if defined(__GNUC__)
112112 #define VPX_NO_RETURN __attribute__((noreturn))
113+#elif defined(_MSC_VER)
114+#define VPX_NO_RETURN __declspec(noreturn)
113115 #else
114116 #define VPX_NO_RETURN
115117 #endif
@@ -117,14 +119,14 @@ extern "C" { · 1 unmodified line
117119 /* Sets a stdio stream into binary mode */
118120 FILE *set_binary_mode(FILE *stream);
119121
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, ...);
122124 void warn(const char *fmt, ...);
123125
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);
125127
126128 /* 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);
128130
129131 #undef VPX_NO_RETURN
130132

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t