[FFmpeg-devel] [PATCH] avutil: Rename RSHIFT macro to ROUNDED_RSHIFT

Uoti Urpala uoti.urpala at pp1.inet.fi
Mon Jan 28 02:28:44 EET 2019

On Mon, 2019-01-28 at 00:04 +0100, Henrik Gramner wrote:
> On Mon, Jan 21, 2019 at 9:54 PM James Almer <jamrial at gmail.com> wrote:
> > There's also no good way to deprecate a define and replace it with
> > another while informing the library user, so for something purely
> > cosmetic like this i don't think it's worth the trouble.
> Would it be possible to create a deprecated inlined function that does
> nothing, and add a call to that function inside the old macro? Kind of
> ugly though.

I already posted that suggestion last Tuesday. It does work trigger a
deprecation warning, but an inline function has the drawback that it's
not a constant expression. If you want to keep backward compatibility
even for uses like initializing global tables or other variables, you
can use a deprecated variable in ways other than a call though. For
example this should be a constant expression that shows a deprecation

// This variable does not need to really exist
extern int __attribute__ ((deprecated)) RSHIFT_is_deprecated;

#define RSHIFT(a, b) (0*(int)sizeof(RSHIFT_is_deprecated) + AV_ROUNDED_SHIFT(a, b))

sizeof counts as a "use" that shows the deprecation warning, while not
creating any actual reference to the variable and being a constant
expression. The (int) cast is there to make 100% sure that the addition
doesn't change anything by changing the type of the expression.

More information about the ffmpeg-devel mailing list