[FFmpeg-user] help: I use av_err2str function in c++, it occurs " error: taking address of temporary array" when build.

Lingjiang Fang vacingfang at hotmail.com
Sun Jun 13 19:13:29 EEST 2021


On Thu, 10 Jun 2021 12:55:08 +0200
"Diederick C. Niehorster" <dcnieho at gmail.com> wrote:

> That macro doesn't work in C++. use:
> 
> char a[AV_ERROR_MAX_STRING_SIZE] = { 0 };
> av_make_error_string(a, AV_ERROR_MAX_STRING_SIZE, errCode_);
> 
> On Thu, Jun 10, 2021 at 12:40 PM 沈海煌 <chain78 at 163.com> wrote:
> >
> > I use av_err2str function in c++, it occurs  " error: taking
> > address of temporary array" when build.
> >
> >
> > I use extern "C" but it doesn't work.
my solution is override the default av_err2str() function in a
specified header file(needn't modify header in FFmpeg), like this:

#ifdef av_err2str
#undef av_err2str
#include <string>
av_always_inline std::string av_err2string(int errnum) {
    char str[AV_ERROR_MAX_STRING_SIZE];
    return av_make_error_string(str, AV_ERROR_MAX_STRING_SIZE, errnum);
}
#define av_err2str(err) av_err2string(err).c_str()
#endif  // av_err2str

or refer here:
https://github.com/joncampbell123/composite-video-simulator/issues/5

> > _______________________________________________
> > ffmpeg-user mailing list
> > ffmpeg-user at ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-user
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".  
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
> 
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".



Regards,
Lingjiang Fang


More information about the ffmpeg-user mailing list