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
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__)
20extern 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#else23#else
22extern void die(const char *fmt, ...);24extern void die(const char *fmt, ...);
23#endif25#endif
tools_common.h+6−4
@@ -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#else115#else
114#define VPX_NO_RETURN116#define VPX_NO_RETURN
115#endif117#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 */
118FILE *set_binary_mode(FILE *stream);120FILE *set_binary_mode(FILE *stream);
119 121
120void die(const char *fmt, ...) VPX_NO_RETURN;122VPX_NO_RETURN void die(const char *fmt, ...);
121void fatal(const char *fmt, ...) VPX_NO_RETURN;123VPX_NO_RETURN void fatal(const char *fmt, ...);
122void warn(const char *fmt, ...);124void warn(const char *fmt, ...);
123 125
124void die_codec(vpx_codec_ctx_t *ctx, const char *s) VPX_NO_RETURN;126VPX_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() */
127void usage_exit(void) VPX_NO_RETURN;129VPX_NO_RETURN void usage_exit(void);
128 130
129#undef VPX_NO_RETURN131#undef VPX_NO_RETURN
130 132

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