[FFmpeg-devel] [PATCH] Const src in av_packet_clone declaration

wm4 nfxjfg at googlemail.com
Fri May 13 11:47:25 CEST 2016


On Fri, 13 May 2016 01:08:45 +0300
Andriy Lysnevych <andriy.lysnevych at gmail.com> wrote:

> > That's a change that could break source-compatibility with C++, I don't  
> think it can be made so easily.
> 
> I do not agree. It extends function so it can take as argument both const
> and non-const packets.
> 
> Actually I discovered this defect when I was not able to clone const packet
> in C++ project.

const is broken anyway, both in C and C++. I recommend not to use it.

Anyway, example how this change can break:

typedef struct AVPacket AVPacket;

AVPacket *av_packet_clone_old(AVPacket *src);
AVPacket *av_packet_clone_new(const AVPacket *src);

AVPacket *(*unsuspecting_api_user)(AVPacket *src);

void set(void)
{
    unsuspecting_api_user = av_packet_clone_old;

    unsuspecting_api_user = av_packet_clone_new;
}


Most C compilers will only warn against it, but in C++ it's always a
hard error.


More information about the ffmpeg-devel mailing list