From c94e03f4458fd1a79fb44e2a37779f2a9db5eacd Mon Sep 17 00:00:00 2001 From: Chih-Wei Huang Date: Mon, 4 Nov 2013 00:06:07 +0800 Subject: libavutil: fix av_err2str compiling error for C++ The implementation may not be thread-safe. But good enough for us. --- libavutil/error.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavutil/error.h b/libavutil/error.h index f3fd7bbff6..a1f68e570b 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -87,6 +87,17 @@ */ int av_strerror(int errnum, char *errbuf, size_t errbuf_size); +#ifdef __cplusplus + +static inline const char *av_err2str(int errnum) +{ + static char errbuf[AV_ERROR_MAX_STRING_SIZE]; + av_strerror(errnum, errbuf, AV_ERROR_MAX_STRING_SIZE); + return errbuf; +} + +#else + /** * Fill the provided buffer with a string containing an error string * corresponding to the AVERROR code errnum. @@ -110,6 +121,7 @@ static inline char *av_make_error_string(char *errbuf, size_t errbuf_size, int e #define av_err2str(errnum) \ av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0}, AV_ERROR_MAX_STRING_SIZE, errnum) +#endif /* __cplusplus */ /** * @} */ -- cgit v1.2.3