[FFmpeg-devel] compound literal in public header file

Tobias Rapp t.rapp at noa-archive.com
Wed May 16 12:16:15 EEST 2018

On 16.05.2018 10:29, Tomas Härdin wrote:
> 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.

ffmpeg.c/ffprobe.c is using it for assembling log messages and I'm using 
it in my private tools, too. As it is a convenient utility function I 
would prefer to keep it in the public headers of libavutil.


More information about the ffmpeg-devel mailing list