[FFmpeg-devel] compound literal in public header file

Tomas Härdin tjoppen at acc.umu.se
Wed May 16 11:29:39 EEST 2018

ons 2018-05-16 klockan 10:18 +0800 skrev Zhao Zhili:
> The av_err2str macro in libavutil/error.h use compound literal:
> #define av_err2str(errnum) \
>      av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0}, 
> C++ compiler may not support it or treat the usage as invalid.
> For example, g++ 5.4 raise an error: taking address of temporary
> array.
> 1. Should the macro be defined for C only?
> 2. Or make it as valid C++? (I don't know how to do that)

First of all, this shouldn't matter since av_err2str is not actually
used in any header. libavutil/timer.h makes use of it in another macro,
so that also doesn't matter.

Second, libavutil is a C library, not a C++ library. However, it might
be nicer to make that a static inline function, if possible. Or move it
to an internal header, since it doesn't look like something that should
be exposed as part of the public API.


More information about the ffmpeg-devel mailing list